/** * Force the initComponent() method implemented in the child class to be called. If this method is called more than * once on a given object, all calls but the first do nothing. */ public synchronized final void initialize() { if ((!_lazyConstructorCalled) && (getParent() != null)) { initComponents(); _lazyConstructorCalled = true; validate(); } }
public void actionPerformed(ActionEvent e) { setDialogResult(RESULT_AFFIRMED); setVisible(false); } };
@Override public JComponent createBannerPanel() { return StandardDialog.this.createBannerPanel(); }
/** * Call three createXxxPanel methods and layout them using BorderLayout. By default, banner panel, content panel and * button panel are added to NORTH, CENTER and SOUTH of BorderLayout respectively. * <p/> * You can override this method if you want to layout them in another way. */ protected void initComponents() { getContentPane().setLayout(new BorderLayout()); _standardDialogPane.initComponents(); getContentPane().add(_standardDialogPane); if (getInitFocusedComponent() != null) { addWindowListener(new WindowAdapter() { @Override public void windowActivated(WindowEvent e) { getInitFocusedComponent().requestFocus(); } }); } }
private void initDialog() { _standardDialogPane = createStandardDialogPane(); _propertyChangeListener = new StandardDialogPropertyChangeListener(); _standardDialogPane.addPropertyChangeListener(_propertyChangeListener); setDefaultCloseOperation(DISPOSE_ON_CLOSE); }
public void propertyChange(PropertyChangeEvent evt) { if (StandardDialogPane.PROPERTY_CANCEL_ACTION.equals(evt.getPropertyName())) { DelegateAction delegateAction = new DelegateAction(getDefaultCancelAction()) { private static final long serialVersionUID = -2136676357204671812L; @Override public boolean delegateActionPerformed(ActionEvent e) { if (hasSelectionPath()) { MenuSelectionManager.defaultManager().clearSelectedPath(); return true; } return false; } @Override public boolean isDelegateEnabled() { return hasSelectionPath(); } private boolean hasSelectionPath() { MenuElement[] selectedPath = MenuSelectionManager.defaultManager().getSelectedPath(); return selectedPath != null && selectedPath.length > 0; } }; getRootPane().unregisterKeyboardAction(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0)); getRootPane().registerKeyboardAction(delegateAction, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW); } else if (StandardDialogPane.PROPERTY_DEFAULT_ACTION.equals(evt.getPropertyName())) { getRootPane().unregisterKeyboardAction(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0)); getRootPane().registerKeyboardAction(getDefaultAction(), KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); } } }
@Override public void setVisible(boolean visible) { if (visible) { pack(); setLocationRelativeTo(getParent()); } super.setVisible(visible); }
@Override protected void initComponents() { super.initComponents(); applyBorders(); }
@Override public ButtonPanel createButtonPanel() { return StandardDialog.this.createButtonPanel(); } }
@Override public JComponent createContentPanel() { return StandardDialog.this.createContentPanel(); }
@Override public void setVisible(boolean b) { if (b) { pack(); //Workaround for dialogs. Overriding #getMinimuSize() is not enough setMinimumSize(getMinimumSize()); //Restore the component size storage if there is one if (componentSizeStorage != null) { Dimension storedSize = componentSizeStorage.get(); if (storedSize != null) { Dimension preferredSize = getPreferredSize(); //ensure at least pref size storedSize.width = Math.max(storedSize.width, preferredSize.width); storedSize.height = Math.max(storedSize.height, preferredSize.height); setSize(storedSize); } } setLocationRelativeTo(getParent()); } super.setVisible(b); }
public void actionPerformed(ActionEvent e) { setDialogResult(RESULT_CANCELLED); setVisible(false); } };