public void testEmptyHeader() { fFrame = new JFrame("Test Window"); // Create a panel to hold all other components JPanel topPanel = new JPanel(); topPanel.setLayout(new BorderLayout()); // Create a new table instance MyTableModel myModel = new MyTableModel(); fTable = new JTable(myModel); // Add the table to a scrolling pane JScrollPane scrollPane = new JScrollPane(fTable); topPanel.add(scrollPane, BorderLayout.CENTER); fFrame.getContentPane().setLayout(new BorderLayout()); fFrame.getContentPane().add(BorderLayout.CENTER, topPanel); fFrame.setSize(400, 450); fFrame.setLocation(20, 20); fFrame.setVisible(true); try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } JTableHeader header = fTable.getTableHeader(); assertTrue( "JTableHeader greater than 5 pixels tall with empty string first element.", header.getSize().height > 5); fFrame.setVisible(false); fFrame.dispose(); }
protected void tearDown() { fFrame.setVisible(false); fFrame.dispose(); }