JXRootPane extends JRootPane { public void setStatusBar(JXStatusBar statusBar) { JXStatusBar oldStatusBar = this.statusBar; this.statusBar = statusBar; Component[] comps = getContentPane().getComponents(); for (int i = 0; i < comps.length; i++) { unregisterStatusBar(comps[i]); registerStatusBar(comps[i]); } if (oldStatusBar != null) { remove(oldStatusBar); } if (statusBar != null) { add(statusBar); } firePropertyChange("statusBar", oldStatusBar, getStatusBar()); } JXRootPane(); @Override void setLayout(LayoutManager layout); void setStatusBar(JXStatusBar statusBar); JXStatusBar getStatusBar(); void setToolBar(JToolBar toolBar); JToolBar getToolBar(); void setCancelButton(JButton cancelButton); JButton getCancelButton();  }
@Test public void testLayoutWithLAFDecoration() { if (GraphicsEnvironment.isHeadless()) { LOG.fine("cannot run testLAFDecorationLayout - headless environment"); return; } if (!UIManager.getLookAndFeel().getSupportsWindowDecorations()) { LOG.info("cannot run test - unsupported laf window decoration"); return; } JFrame.setDefaultLookAndFeelDecorated(true); JXFrame frame = new JXFrame(); frame.add(new JXTable(new AncientSwingTeam())); frame.pack(); Dimension dim = frame.getSize(); assertEquals(dim, frame.getPreferredSize()); JXStatusBar bar = new JXStatusBar(); bar.add(new JLabel("need some content")); frame.setStatusBar(bar); frame.pack(); try { assertEquals(dim.height + bar.getPreferredSize().height, frame.getPreferredSize().height); } finally { JFrame.setDefaultLookAndFeelDecorated(false); } }
@Test public void testLayoutWithOut() { if (GraphicsEnvironment.isHeadless()) { LOG.fine("cannot run testLAFDecorationLayout - headless environment"); return; } JXFrame frame = new JXFrame(); frame.add(new JXTable(new AncientSwingTeam())); frame.pack(); Dimension dim = frame.getSize(); assertEquals(dim, frame.getPreferredSize()); JXStatusBar bar = new JXStatusBar(); bar.add(new JLabel("need some content")); frame.setStatusBar(bar); frame.pack(); try { assertEquals(dim.height + bar.getPreferredSize().height, frame.getPreferredSize().height); } finally { JFrame.setDefaultLookAndFeelDecorated(false); } }
@Test public void testStatusBarSet() { JXRootPane rootPane = new JXRootPane(); JXStatusBar toolBar = new JXStatusBar(); rootPane.setStatusBar(toolBar); assertTrue(SwingUtilities.isDescendingFrom(toolBar, rootPane)); rootPane.setStatusBar(new JXStatusBar()); assertFalse(SwingUtilities.isDescendingFrom(toolBar, rootPane)); }
@Test public void testStatusBarFirePropertyChange() { JXRootPane rootPane = new JXRootPane(); JXStatusBar toolBar = new JXStatusBar(); rootPane.setStatusBar(toolBar); assertTrue(SwingUtilities.isDescendingFrom(toolBar, rootPane)); PropertyChangeReport report = new PropertyChangeReport(); rootPane.addPropertyChangeListener(report); rootPane.setStatusBar(new JXStatusBar()); assertEquals("set statusBar must have fire exactly one property change", 1, report.getEventCount()); assertTrue(report.hasEvents("statusBar")); }
@Test public void testStatusBarNPE() { JXRootPane rootPane = new JXRootPane(); rootPane.setStatusBar(null); }