Example usage for javax.swing JButton setDefaultCapable

List of usage examples for javax.swing JButton setDefaultCapable

Introduction

In this page you can find the example usage for javax.swing JButton setDefaultCapable.

Prototype

@BeanProperty(visualUpdate = true, description = "Whether or not this button can be the default button")
public void setDefaultCapable(boolean defaultCapable) 

Source Link

Document

Sets the defaultCapable property, which determines whether this button can be made the default button for its root pane.

Usage

From source file:Main.java

private static void initHelpButton(final JButton buttonHelp) {
    buttonHelp.setMnemonic(KeyEvent.VK_H);
    buttonHelp.setDefaultCapable(false);
}

From source file:Main.java

private static void initCancelButton(final JButton buttonCancel) {
    buttonCancel.setMnemonic(KeyEvent.VK_C);
    buttonCancel.setDefaultCapable(false);
}

From source file:com.github.kennycyb.uifactory.core.factory.impl.components.swing.JButtonFactory.java

@UiAnnotationHandler(UiDefaultButton.class)
public void handleUiDefaultButton(final ComponentContext context, final JButton component,
        final UiDefaultButton annotate) {
    component.setDefaultCapable(true);
}

From source file:MainClass.java

MainClass(String title) {
    super(title);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JButton jb = new JButton("Ok", new ImageIcon("bullet.gif"));
    jb.setHorizontalAlignment(SwingConstants.LEFT);
    jb.setMnemonic('O');

    getContentPane().add(jb, BorderLayout.CENTER);

    jb = new JButton("<html><i>Cancel</i></html>");
    jb.setVerticalAlignment(SwingConstants.BOTTOM);

    jb.setDefaultCapable(true);

    getContentPane().add(jb, BorderLayout.EAST);

    getRootPane().setDefaultButton(jb);//www .java2 s  . c  o  m

    setSize(200, 100);
    setVisible(true);
}

From source file:org.pentaho.reporting.engine.classic.core.modules.gui.base.AbstractExportDialog.java

protected JPanel createButtonPanel() {
    final JButton btnCancel = new JButton(getCancelAction());
    final JButton btnConfirm = new JButton(getConfirmAction());
    final JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new GridLayout(1, 2, 5, 5));
    buttonPanel.add(btnConfirm);//from w  w w. j a  va2s  .com
    buttonPanel.add(btnCancel);
    btnConfirm.setDefaultCapable(true);
    getRootPane().setDefaultButton(btnConfirm);
    buttonPanel.registerKeyboardAction(getConfirmAction(), KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0),
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);

    final JPanel buttonCarrier = new JPanel();
    buttonCarrier.setLayout(new FlowLayout(FlowLayout.RIGHT));
    buttonCarrier.add(buttonPanel);
    return buttonCarrier;
}

From source file:org.pentaho.reporting.engine.classic.core.modules.gui.base.PreviewParametersDialog.java

private JPanel createButtonsPanel() {
    final JButton okButton = new JButton(confirmAction);
    okButton.setDefaultCapable(true);

    final JPanel buttonsPanel = new JPanel();
    buttonsPanel.setLayout(new FlowLayout(FlowLayout.RIGHT, 5, 5));
    buttonsPanel.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, Color.LIGHT_GRAY));
    buttonsPanel.add(okButton);/*w w w .j a  v a2 s .  c om*/
    buttonsPanel.add(new JButton(new CancelAction()));
    return buttonsPanel;
}

From source file:phex.gui.dialogs.UpdateNotificationDialog.java

private void prepareComponent() {
    CloseEventHandler closeEventHandler = new CloseEventHandler();
    addWindowListener(closeEventHandler);

    Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());

    JPanel contentPanel = new JPanel();
    //JPanel contentPanel = new FormDebugPanel();
    contentPane.add(contentPanel, BorderLayout.CENTER);

    CellConstraints cc = new CellConstraints();
    FormLayout layout = new FormLayout("2dlu, fill:d:grow, 2dlu", // columns
            "p, p, 16dlu, fill:p:grow, 16dlu," + // rows
                    "p, 2dlu, p 4dlu"); //btn rows
    PanelBuilder contentPB = new PanelBuilder(layout, contentPanel);
    int columnCount = layout.getColumnCount();
    int rowCount = layout.getRowCount();

    DialogBanner banner = new DialogBanner(Localizer.getString("UpdateNotification_BannerHeader"),
            Localizer.getString("UpdateNotification_BannerSubHeader"));
    contentPB.add(banner, cc.xywh(1, 1, columnCount, 1));

    contentPB.add(new JSeparator(), cc.xywh(1, 2, columnCount, 1));

    JPanel notifyPanel = buildNotificationPanel();
    contentPB.add(notifyPanel, cc.xy(2, 4, "center, center"));

    contentPB.add(new JSeparator(), cc.xywh(1, rowCount - 3, columnCount, 1));

    JButton closeBtn = new JButton(Localizer.getString("Close"));
    closeBtn.addActionListener(closeEventHandler);
    JButton downloadBtn = new JButton(Localizer.getString("Download"));
    downloadBtn.setDefaultCapable(true);
    downloadBtn.setRequestFocusEnabled(true);
    downloadBtn.addActionListener(new DownloadBtnListener());
    JPanel btnPanel = ButtonBarFactory.buildOKCancelBar(downloadBtn, closeBtn);
    contentPB.add(btnPanel, cc.xywh(2, rowCount - 1, columnCount - 2, 1));

    setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    getRootPane().setDefaultButton(downloadBtn);

    pack();/*from   ww w  .j av a  2  s .  c  o m*/
    setLocationRelativeTo(getParent());
}