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

JTable fails to draw Column Header if first header is assigned an empty string

XMLWordPrintable

    • beta
    • x86, sparc
    • solaris_2.6, windows_nt
    • Verified

      Build : 'I' (last build work: 'A', unable to test B, C failed in 'D')
                according to our 2D eng build bringovers, it worked on 19-May but
                failed on 20-May.
      OS : all platforms.
      app : Java2Demo.jar (sub demo: Intro)
                execution: java -cp Java2Demo.jar Intro
                {right click on border to get to the JTable}

      This particular panel calls up a lightweight JTable with Column Headers, but headers fails to appear.


      import javax.swing.JTable;
      import javax.swing.JScrollPane;
      import javax.swing.JPanel;
      import javax.swing.JFrame;
      import java.awt.*;
      import java.awt.event.*;

      public class ColHeaderBug extends JFrame {

          public ColHeaderBug() {super("ColHeaderBug");

              Object[][] data = {
      {"r1c1", "col2", "col3"},
      {"r2c1", "col2", "col3"},
      {"r3c1", "col2", "col3"},
      {"r4c1", "col2", "col3"},
              };

              String[] columnNames = {"",
                                      "Column 2",
                                      "Column 3"};

              final JTable table = new JTable(data, columnNames);
              table.setPreferredScrollableViewportSize(new Dimension(200, 100));
              JScrollPane scrollPane = new JScrollPane(table);
              getContentPane().add(scrollPane, BorderLayout.CENTER);

              addWindowListener(new WindowAdapter() {
                  public void windowClosing(WindowEvent e) {
                      System.exit(0);
                  }
              });
          }


          public static void main(String[] args) {
              ColHeaderBug frame = new ColHeaderBug();
              frame.pack();
              frame.setVisible(true);
          }
      }

            pmilnesunw Philip Milne (Inactive)
            rckim Robert Kim (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: