protected JPanel createButtonsPane() { final JButton button = new JButton( getConfirmAction() ); button.setDefaultCapable( true ); final JPanel buttonsPanel = new JPanel(); buttonsPanel.setLayout( new FlowLayout( FlowLayout.RIGHT, 5, 5 ) ); if ( !MacOSXIntegration.MAC_OS_X ) { buttonsPanel.add( button ); } if ( hasCancelButton() ) { buttonsPanel.add( new JButton( getCancelAction() ) ); } if ( MacOSXIntegration.MAC_OS_X ) { buttonsPanel.add( button ); } final JPanel extraPanel = new JPanel(); extraPanel.setLayout( new FlowLayout( FlowLayout.LEFT, 5, 5 ) ); final Action[] extraActions = getExtraActions(); for ( int i = 0; i < extraActions.length; i++ ) { final Action action = extraActions[ i ]; extraPanel.add( new JButton( action ) ); } final JPanel buttonsCarrierPanel = new JPanel(); buttonsCarrierPanel.setLayout( new BorderLayout( 5, 5 ) ); buttonsCarrierPanel.add( buttonsPanel, BorderLayout.EAST ); buttonsCarrierPanel.add( extraPanel, BorderLayout.WEST ); return buttonsCarrierPanel; }
protected void init() { dialogSizeSettings = new DialogSizeSettings(); buttonPaneVisible = true; confirmAction = new OKAction(); cancelAction = new CancelAction(); setDefaultCloseOperation( DISPOSE_ON_CLOSE ); final JPanel contentPane = new JPanel(); contentPane.setLayout( new BorderLayout() ); buttonPanel = createButtonsPane(); contentPane.add( createContentPane(), BorderLayout.CENTER ); contentPane.add( buttonPanel, BorderLayout.SOUTH ); setContentPane( contentPane ); final InputMap inputMap = contentPane.getInputMap( JComponent.WHEN_IN_FOCUSED_WINDOW ); final ActionMap actionMap = contentPane.getActionMap(); inputMap.put( KeyStroke.getKeyStroke( KeyEvent.VK_ENTER, 0 ), "confirm" ); // NON-NLS inputMap.put( KeyStroke.getKeyStroke( KeyEvent.VK_ESCAPE, 0 ), "cancel" ); // NON-NLS actionMap.put( "confirm", getConfirmAction() ); // NON-NLS actionMap.put( "cancel", getCancelAction() ); // NON-NLS resizeDialog(); }