/** Repaints the window according to whether the window is currently collapsed or expanded. */ void updateCollapsedState() { SizeButton button = (SizeButton) titleBar.getButton(TitleBar.SIZE_BUTTON); if (window.isCollapsed()) { removeComponent(canvas); Dimension d = new Dimension(window.getWidth(), TitleBar.HEIGHT + 2 * BORDER_THICKNESS); titleBar.setPreferredSize(d); button.setActionType(SizeButton.EXPAND); window.setSize(d.width, d.height); } else { addComponent(canvas); button.setActionType(SizeButton.COLLAPSE); Dimension dT = titleBar.getPreferredSize(); Dimension dW = window.getRestoreSize(); window.setSize(dT.width, dW.height); } window.validate(); window.repaint(); }
/** * Attaches the <code>controller</code> to the buttons of the titleBar. * * @param controller An instance of {@link DialogControl}. */ void attachActionListener(ActionListener controller) { attachButtonListener(controller, titleBar.getButton(TitleBar.SIZE_BUTTON), DialogControl.SIZE); attachButtonListener( controller, titleBar.getButton(TitleBar.CLOSE_BUTTON), DialogControl.CLOSE); }