JXRootPane extends JRootPane { public void setToolBar(JToolBar toolBar) { JToolBar oldToolBar = getToolBar(); this.toolBar = toolBar; if (oldToolBar != null) { getContentPane().remove(oldToolBar); } getContentPane().add(BorderLayout.NORTH, this.toolBar); getContentPane().validate(); firePropertyChange("toolBar", oldToolBar, getToolBar()); } 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 testToolBarSet() { JXRootPane rootPane = new JXRootPane(); JToolBar toolBar = new JToolBar(); rootPane.setToolBar(toolBar); assertTrue(SwingUtilities.isDescendingFrom(toolBar, rootPane)); rootPane.setToolBar(new JToolBar()); assertFalse(SwingUtilities.isDescendingFrom(toolBar, rootPane)); }
@Test public void testToolBarFirePropertyChange() { JXRootPane rootPane = new JXRootPane(); JToolBar toolBar = new JToolBar(); rootPane.setToolBar(toolBar); assertTrue(SwingUtilities.isDescendingFrom(toolBar, rootPane)); PropertyChangeReport report = new PropertyChangeReport(); rootPane.addPropertyChangeListener(report); rootPane.setToolBar(new JToolBar()); assertEquals(1, report.getEventCount()); assertTrue(report.hasEvents("toolBar")); }