Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4492484

Win L&F: JTable fails to draw header containing empty string under Windows Look-

    XMLWordPrintable

Details

    • beta
    • generic, x86
    • generic, windows_2000

    Backports

      Description

        Name: yyT116575 Date: 08/15/2001


        java version "1.3.0"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
        Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)

        java version "1.4.0-beta"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b65)
        Java HotSpot(TM) Client VM (build 1.4.0-beta-b65, mixed mode)

        When using the Windows Look-and-Feel, JTable renders header
        with zero height if the first column has empty title ("").

        The following example demonstrates the problem:


        import javax.swing.*;
        import javax.swing.table.*;

        public class SwingHeaderProblem extends JFrame {

          static String columnNames[] = {"", "First", "Last"};

          SwingHeaderProblem() {

            TableModel dataModel = new AbstractTableModel() {
              public String getColumnName(int col) {return columnNames[col];}
              public int getColumnCount() { return columnNames.length; }
              public int getRowCount() { return 8; }
              public Object getValueAt(int row, int col) {
                switch(col) {
                  case 0: return "x"; break;
                  case 1: return "John"; break;
                  case 2: return "Smith"; break;
                  default: return null;
                }
              }
            };
            JTable table = new JTable(dataModel);
            JScrollPane scrollPane = new JScrollPane(table);
            getContentPane().add(scrollPane);
          }


          public void setVisible(boolean b) {
            if (!b) System.exit(0);
          }

          public static void main(String[] args) {
            try {
              UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
            } catch (Exception ex) {
              ex.printStackTrace();
              System.exit(-1);
            }
            SwingHeaderProblem w = new SwingHeaderProblem();
            w.setSize(300,200);
            w.show();

          }
        }

        (Review ID: 130031)
        ======================================================================

        Attachments

          Issue Links

            Activity

              People

                kereminsunw Konstantin Eremin (Inactive)
                yyoungsunw Yung-ching Young (Inactive)
                Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: