当前位置: 首页>>代码示例>>Java>>正文


Java JButton.setDefaultCapable方法代码示例

本文整理汇总了Java中javax.swing.JButton.setDefaultCapable方法的典型用法代码示例。如果您正苦于以下问题:Java JButton.setDefaultCapable方法的具体用法?Java JButton.setDefaultCapable怎么用?Java JButton.setDefaultCapable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JButton的用法示例。


在下文中一共展示了JButton.setDefaultCapable方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: display

import javax.swing.JButton; //导入方法依赖的package包/类
/** Displays dialog. */
public boolean display() {
    String title = NbBundle.getMessage(RunTargetsAction.class, "TITLE_run_advanced");
    DialogDescriptor dd = new DialogDescriptor(this, title);
    dd.setOptionType(NotifyDescriptor.OK_CANCEL_OPTION);
    JButton run = new JButton(NbBundle.getMessage(RunTargetsAction.class, "LBL_run_advanced_run"));
    run.setDefaultCapable(true);
    JButton cancel = new JButton(NbBundle.getMessage(RunTargetsAction.class, "LBL_run_advanced_cancel"));
    dd.setOptions(new Object[] {run, cancel});
    dd.setModal(true);
    Object result = DialogDisplayer.getDefault().notify(dd);
    if (result.equals(run)) {
        try {
            run();
            return true;
        } catch (IOException x) {
            AntModule.err.notify(x);
        }
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:AdvancedActionPanel.java

示例2: showAcceptCancelDialog

import javax.swing.JButton; //导入方法依赖的package包/类
/**
 * Show an OK/cancel-type dialog with customized button texts.
 * Only a separate method because it is otherwise cumbersome to replace
 * the OK button with a button that is set as the default.
 * @param title the dialog title
 * @param message the body of the message (usually HTML text)
 * @param acceptButton a label for the default accept button; should not use mnemonics
 * @param accDescrAcceptButton a accessible description for acceptButton 
 * @param cancelButton a label for the cancel button (or null for default); should not use mnemonics
 * @param messageType {@link NotifyDescriptor#WARNING_MESSAGE} or similar
 * @return true if user accepted the dialog
 */
public static boolean showAcceptCancelDialog(String title, String message, 
        String acceptButton, String accDescrAcceptButton , 
        String cancelButton, int messageType) 
{
    DialogDescriptor d = new DialogDescriptor(message, title);
    d.setModal(true);
    JButton accept = new JButton(acceptButton);
    accept.setDefaultCapable(true);
    if ( accDescrAcceptButton != null ){
        accept.getAccessibleContext().
        setAccessibleDescription( accDescrAcceptButton);
    }
    d.setOptions(new Object[] {
        accept,
        cancelButton != null ? new JButton(cancelButton) : NotifyDescriptor.CANCEL_OPTION,
    });
    d.setMessageType(messageType);
    return DialogDisplayer.getDefault().notify(d).equals(accept);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:ApisupportAntUIUtils.java

示例3: actionPerformed

import javax.swing.JButton; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
    String title = NbBundle.getMessage(RunTargetsAction.class, "TITLE_run_advanced");
    AdvancedActionPanel panel = new AdvancedActionPanel(project, allTargets);
    DialogDescriptor dd = new DialogDescriptor(panel, title);
    dd.setOptionType(NotifyDescriptor.OK_CANCEL_OPTION);
    JButton run = new JButton(NbBundle.getMessage(RunTargetsAction.class, "LBL_run_advanced_run"));
    run.setDefaultCapable(true);
    JButton cancel = new JButton(NbBundle.getMessage(RunTargetsAction.class, "LBL_run_advanced_cancel"));
    dd.setOptions(new Object[] {run, cancel});
    dd.setModal(true);
    Object result = DialogDisplayer.getDefault().notify(dd);
    if (result.equals(run)) {
        try {
            panel.run();
        } catch (IOException x) {
            AntModule.err.notify(x);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:RunTargetsAction.java

示例4: showDetails

import javax.swing.JButton; //导入方法依赖的package包/类
private static void showDetails(RunningVM vm) {
    HTMLTextArea area = new HTMLTextArea();
    JScrollPane areaScroll = new JScrollPane(area, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
                                                   JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    areaScroll.setBorder(BorderFactory.createEmptyBorder());
    areaScroll.setViewportBorder(BorderFactory.createEmptyBorder());
    areaScroll.setPreferredSize(new Dimension(500, 260));
    configureScrollBar(areaScroll.getVerticalScrollBar());
    configureScrollBar(areaScroll.getHorizontalScrollBar());
    
    area.setText(getDetails(vm));
    area.setCaretPosition(0);
    
    HelpCtx helpCtx = new HelpCtx("ProcessDetails.HelpCtx"); //NOI18N
    JButton close = new JButton(Bundle.AttachDialog_BtnClose());
    close.setDefaultCapable(true);
    DialogDescriptor dd = new DialogDescriptor(areaScroll, Bundle.AttachDialog_DetailsCaption(getProcessName(vm.getMainClass())),
                          true, new Object[] { close }, close, DialogDescriptor.DEFAULT_ALIGN, helpCtx, null);
    Dialog d = DialogDisplayer.getDefault().createDialog(dd);
    d.pack();
    d.setVisible(true);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:AttachDialog.java

示例5: actionPerformed

import javax.swing.JButton; //导入方法依赖的package包/类
public void actionPerformed (ActionEvent evt) {
    bOk = new JButton (NbBundle.getMessage (ConnectAction.class, "CTL_Ok")); // NOI18N
    bCancel = new JButton (NbBundle.getMessage (ConnectAction.class, "CTL_Cancel")); // NOI18N
    bOk.getAccessibleContext ().setAccessibleDescription (NbBundle.getMessage (ConnectAction.class, "ACSD_CTL_Ok")); // NOI18N
    bCancel.getAccessibleContext ().setAccessibleDescription (NbBundle.getMessage (ConnectAction.class, "ACSD_CTL_Cancel")); // NOI18N
    bCancel.setDefaultCapable(false);
    cp = new ConnectorPanel ();
    descr = new DialogDescriptor (
        cp,
        NbBundle.getMessage (ConnectAction.class, "CTL_Connect_to_running_process"),
        true, // modal
        new ConnectListener (cp)
    );
    descr.setOptions (new JButton[] {
        bOk, bCancel
    });
    notificationSupport = descr.createNotificationLineSupport();
    descr.setClosingOptions (new Object [0]);
    descr.setHelpCtx(HelpCtx.findHelp(cp)); // This is mandatory so that the descriptor tracks the changes in help correctly.
    dialog = DialogDisplayer.getDefault ().createDialog (descr);
    dialog.setVisible(true);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:ConnectAction.java

示例6: showDialog

import javax.swing.JButton; //导入方法依赖的package包/类
private Variable showDialog() {
    JPanel inset = new JPanel(new BorderLayout());
    inset.setBorder(new EmptyBorder(12,12,0,12));
    inset.add(this);
    inset.getAccessibleContext().setAccessibleName(NbBundle.getMessage(VariablesPanel.class, "AN_Manage_Variables"));
    inset.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(VariablesPanel.class, "AD_Manage_Variables"));
    DialogDescriptor dd = new DialogDescriptor(inset, NbBundle.getMessage(VariablesPanel.class, "TITLE_Manage_Variables")); // NOI18N
    dd.setModal(true);
    final JButton ok = new JButton(NbBundle.getMessage(VariablesPanel.class, "BUTTON_OK")); // NOI18N
    ok.setDefaultCapable(true);
    explorer.addPropertyChangeListener(new PropertyChangeListener() {
       public void propertyChange(PropertyChangeEvent evt) {
           removeButton.setEnabled(explorer.getSelectedNodes().length > 0);
           editButton.setEnabled(explorer.getSelectedNodes().length == 1);
       }
    });
    dd.setOptions(new Object[] {ok, NotifyDescriptor.CANCEL_OPTION});
    dd.setClosingOptions(new Object[] {ok, NotifyDescriptor.CANCEL_OPTION});
    if (DialogDisplayer.getDefault().notify(dd) == ok) {
        model.save();
        if (explorer.getSelectedNodes().length == 1) {
            return explorer.getSelectedNodes()[0].getLookup().lookup(Variable.class);
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:VariablesPanel.java

示例7: createGUI

import javax.swing.JButton; //导入方法依赖的package包/类
private static void createGUI() {
    frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JButton button = new JButton("Default button");
    button.setDefaultCapable(true);
    button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            ButtonClickCount++;
        }
    });

    frame.add(button);
    button.setVisible(false);

    frame.getRootPane().setDefaultButton(button);

    frame.setSize(200, 200);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:HiddenDefaultButtonTest.java

示例8: alert

import javax.swing.JButton; //导入方法依赖的package包/类
/**
 * Display an alert asking the user whether to really generate a target.
 * @param commandDisplayName the display name of the action to be bound
 * @param scriptPath the path that to the script that will be generated or written to
 * @return true if IDE should proceed
 */
private boolean alert(String commandDisplayName, String scriptPath) {
    String projectDisplayName = ProjectUtils.getInformation(project).getDisplayName();
    String title = NbBundle.getMessage(JavaActions.class, "TITLE_generate_target_dialog", commandDisplayName, projectDisplayName);
    String body = NbBundle.getMessage(JavaActions.class, "TEXT_generate_target_dialog", commandDisplayName, scriptPath);
    NotifyDescriptor d = new NotifyDescriptor.Message(body, NotifyDescriptor.QUESTION_MESSAGE);
    d.setTitle(title);
    d.setOptionType(NotifyDescriptor.OK_CANCEL_OPTION);
    JButton generate = new JButton(NbBundle.getMessage(JavaActions.class, "LBL_generate"));
    generate.setDefaultCapable(true);
    d.setOptions(new Object[] {generate, NotifyDescriptor.CANCEL_OPTION});
    return DialogDisplayer.getDefault().notify(d) == generate;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:JavaActions.java

示例9: NotifyExcPanel

import javax.swing.JButton; //导入方法依赖的package包/类
/** Constructor.
*/
private NotifyExcPanel () {
    java.util.ResourceBundle bundle = org.openide.util.NbBundle.getBundle(NotifyExcPanel.class);
    next = new JButton ();
    Mnemonics.setLocalizedText(next, bundle.getString("CTL_NextException"));
    // bugfix 25684, don't set Previous/Next as default capable
    next.setDefaultCapable (false);
    previous = new JButton ();
    Mnemonics.setLocalizedText(previous, bundle.getString("CTL_PreviousException"));
    previous.setDefaultCapable (false);
    details = new JButton ();
    details.setDefaultCapable (false);

    output = new JTextPane() {
        public @Override boolean getScrollableTracksViewportWidth() {
            return false;
        }
    };
    output.setEditable(false);
    Font f = output.getFont();
    output.setFont(new Font("Monospaced", Font.PLAIN, null == f ? 12 : f.getSize() + 1)); // NOI18N
    output.setForeground(UIManager.getColor("Label.foreground")); // NOI18N
    output.setBackground(UIManager.getColor("Label.background")); // NOI18N

    setLayout( new BorderLayout() );
    add(new JScrollPane(output));
    setBorder( new javax.swing.border.BevelBorder(javax.swing.border.BevelBorder.LOWERED));
        
    next.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_NextException"));
    previous.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_PreviousException"));
    output.getAccessibleContext().setAccessibleName(bundle.getString("ACSN_ExceptionStackTrace"));
    output.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_ExceptionStackTrace"));
    getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_NotifyExceptionPanel"));

    descriptor = new DialogDescriptor ("", ""); // NOI18N

    descriptor.setMessageType (DialogDescriptor.ERROR_MESSAGE);
    descriptor.setOptions (computeOptions(previous, next));
    descriptor.setAdditionalOptions (new Object[] {
                                         details
                                     });
    descriptor.setClosingOptions (new Object[0]);
    descriptor.setButtonListener (this);

    // bugfix #27176, create dialog in modal state if some other modal
    // dialog is opened at the time
    // #53328 do not let the error dialog to be created modal unless the main
    // window is visible. otherwise the error message may be hidden behind
    // the main window thus making the main window unusable
    descriptor.setModal( isModalDialogPresent() 
            && WindowManager.getDefault().getMainWindow().isVisible() );
    
    setPreferredSize(new Dimension(SIZE_PREFERRED_WIDTH + extraW, SIZE_PREFERRED_HEIGHT + extraH));

    dialog = DialogDisplayer.getDefault().createDialog(descriptor);
    if( null != lastBounds ) {
        lastBounds.width = Math.max( lastBounds.width, SIZE_PREFERRED_WIDTH+extraW );
        dialog.setBounds( lastBounds );
    }
    
    dialog.getAccessibleContext().setAccessibleName(bundle.getString("ACN_NotifyExcPanel_Dialog")); // NOI18N
    dialog.getAccessibleContext().setAccessibleDescription(bundle.getString("ACD_NotifyExcPanel_Dialog")); // NOI18N
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:65,代码来源:NotifyExcPanel.java


注:本文中的javax.swing.JButton.setDefaultCapable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。