javax.swing.JButton.setDefaultCapable()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(11.8k)|赞(0)|评价(0)|浏览(287)

本文整理了Java中javax.swing.JButton.setDefaultCapable()方法的一些代码示例,展示了JButton.setDefaultCapable()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JButton.setDefaultCapable()方法的具体详情如下:
包路径:javax.swing.JButton
类名称:JButton
方法名:setDefaultCapable

JButton.setDefaultCapable介绍

暂无

代码示例

代码示例来源:origin: nodebox/nodebox

downloadButton.setDefaultCapable(true);
downloadButton.requestFocus();
downloadButton.addActionListener(new ActionListener() {

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-visualweb-jsfsupport-designtime

private void cmbExampleFocusLost(java.awt.event.FocusEvent evt) {
  // TODO add your handling code here:
  btnTest.setDefaultCapable(false);
}

代码示例来源:origin: robo-code/robocode

public JButton getFindNextButton() {
  if (findNextButton == null) {
    findNextButton = new JButton();
    findNextButton.setText("Find Next");
    findNextButton.setMnemonic('F');
    findNextButton.setDefaultCapable(true);
    findNextButton.addActionListener(this);
  }
  return findNextButton;
}

代码示例来源:origin: robo-code/robocode

public JButton getReplaceButton() {
  if (replaceButton == null) {
    replaceButton = new JButton();
    replaceButton.setText("Replace");
    replaceButton.setMnemonic('R');
    replaceButton.setDefaultCapable(true);
    replaceButton.addActionListener(this);
  }
  return replaceButton;
}

代码示例来源:origin: robo-code/robocode

public JButton getActivateButton() {
  if (activateButton == null) {
    activateButton = new JButton();
    activateButton.setText("Activate");
    activateButton.setMnemonic('A');
    activateButton.setDefaultCapable(true);
    activateButton.addActionListener(this);
  }
  return activateButton;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-visualweb-jsfsupport-designtime

private void cmbExampleFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_cmbExampleFocusGained
  //btnOK.setDefaultCapable(false);
  btnTest.setDefaultCapable(true);
  getRootPane().setDefaultButton(btnTest);
}//GEN-LAST:event_cmbExampleFocusGained

代码示例来源:origin: pentaho/pentaho-reporting

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 );
 buttonsPanel.add( new JButton( new CancelAction() ) );
 return buttonsPanel;
}

代码示例来源:origin: Baralga/baralga

/**
 * This method initializes addProjectButton    .
 * @return javax.swing.JButton    
 */
private JButton getAddProjectButton() {
  if (addProjectButton == null) {
    addProjectButton = new JButton(new ImageIcon(getClass().getResource("/icons/gtk-add.png")));
    addProjectButton.setText(textBundle.textFor("ManageProjectsDialog.AddProjectButton.Title")); //$NON-NLS-1$
    addProjectButton.setToolTipText(textBundle.textFor("ManageProjectsDialog.AddProjectButton.ToolTipText")); //$NON-NLS-1$
    addProjectButton.addActionListener(new java.awt.event.ActionListener() {   
      public void actionPerformed(final java.awt.event.ActionEvent e) {
        String projectName = getNewProjectTextField().getText();
        model.addProject(new Project(RandomUtils.nextLong(), projectName, projectName), ManageProjectsDialog.this);
        getNewProjectTextField().setText(""); //$NON-NLS-1$
      }
    });
    addProjectButton.setDefaultCapable(true);
  }
  return addProjectButton;
}

代码示例来源:origin: pentaho/pentaho-reporting

private 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 );
 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;
}

代码示例来源:origin: pentaho/pentaho-reporting

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 );
 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;
}

代码示例来源:origin: org.xworker/xworker_core

public static void init(JButton jbutton, Thing self, Container parent, ActionContext actionContext){
    AbstractButtonCreator.init(jbutton, self, parent, actionContext);
        
    Boolean defaultCapable = JavaCreator.createBoolean(self, "defaultCapable");
    if(defaultCapable != null){
      jbutton.setDefaultCapable(defaultCapable);
    }
  }
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-ruby-project

protected static boolean showModifiedMessage(String title) {
  String message = NbBundle.getMessage(SharedRubyProjectProperties.class, "TXT_Regenerate");
  JButton regenerateButton = new JButton(NbBundle.getMessage(SharedRubyProjectProperties.class, "CTL_RegenerateButton"));
  regenerateButton.setDefaultCapable(true);
  regenerateButton.getAccessibleContext().setAccessibleDescription(
      NbBundle.getMessage(SharedRubyProjectProperties.class, "AD_RegenerateButton"));
  NotifyDescriptor d = new NotifyDescriptor.Message(message, NotifyDescriptor.WARNING_MESSAGE);
  d.setTitle(title);
  d.setOptionType(NotifyDescriptor.OK_CANCEL_OPTION);
  d.setOptions(new Object[]{regenerateButton, NotifyDescriptor.CANCEL_OPTION});
  return DialogDisplayer.getDefault().notify(d) == regenerateButton;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-j2ee-clientproject

private static boolean showModifiedMessage (String title) {
  String message = NbBundle.getMessage(AppClientProjectProperties.class,"TXT_Regenerate");
  JButton regenerateButton = new JButton (NbBundle.getMessage(AppClientProjectProperties.class,"CTL_RegenerateButton"));
  regenerateButton.setDefaultCapable(true);
  regenerateButton.getAccessibleContext().setAccessibleDescription (NbBundle.getMessage(AppClientProjectProperties.class,"AD_RegenerateButton"));
  NotifyDescriptor d = new NotifyDescriptor.Message (message, NotifyDescriptor.WARNING_MESSAGE);
  d.setTitle(title);
  d.setOptionType(NotifyDescriptor.OK_CANCEL_OPTION);
  d.setOptions(new Object[] {regenerateButton, NotifyDescriptor.CANCEL_OPTION});        
  return DialogDisplayer.getDefault().notify(d) == regenerateButton;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-apisupport-installer

public @Override void run() {
    DialogDescriptor d = new DialogDescriptor(
        NbBundle.getMessage(BuildInstallersAction.class, "BuildInstallersAction.NotConfigured.Warning.Message"),
        NbBundle.getMessage(BuildInstallersAction.class, "BuildInstallersAction.NotConfigured.Warning.Title"));
    d.setModal(true);
    JButton accept = new JButton(NbBundle.getMessage(BuildInstallersAction.class, "BuildInstallersAction.NotConfigured.Warning.OK"));
    accept.setDefaultCapable(true);
    d.setOptions(new Object[]{
          accept});
    d.setMessageType(NotifyDescriptor.WARNING_MESSAGE);
    if (DialogDisplayer.getDefault().notify(d).equals(accept)) {
      //SuiteCustomizer cpi = prj.getLookup().lookup(org.netbeans.modules.apisupport.project.ui.customizer.SuiteCustomizer.class);
      //cpi.showCustomizer(SuiteCustomizer.APPLICATION, SuiteCustomizer.APPLICATION_CREATE_STANDALONE_APPLICATION);
    }
  }
});

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-apisupport-installer

public @Override void run() {
    DialogDescriptor d = new DialogDescriptor(
        NbBundle.getMessage(BuildInstallersAction.class, "BuildInstallersAction.NotApp.Warning.Message"),
        NbBundle.getMessage(BuildInstallersAction.class, "BuildInstallersAction.NotApp.Warning.Title"));
    d.setModal(true);
    JButton accept = new JButton(NbBundle.getMessage(BuildInstallersAction.class, "BuildInstallersAction.NotApp.Warning.OK"));
    accept.setDefaultCapable(true);
    d.setOptions(new Object[]{
          accept});
    d.setMessageType(NotifyDescriptor.WARNING_MESSAGE);
    if (DialogDisplayer.getDefault().notify(d).equals(accept)) {
      //SuiteCustomizer cpi = prj.getLookup().lookup(org.netbeans.modules.apisupport.project.ui.customizer.SuiteCustomizer.class);
      //cpi.showCustomizer(SuiteCustomizer.APPLICATION, SuiteCustomizer.APPLICATION_CREATE_STANDALONE_APPLICATION);
    }
  }
});

代码示例来源:origin: net.sf.taverna.t2.ui-exts/perspective-biocatalogue

/**
 * This method initializes this
 * 
 */
private void initialize() {
  this.setSize(new Dimension(515, 321));
  this.setTitle("Test Service Catalogue API Caller");
  this.setContentPane(getJContentPane());
  
  this.bSubmitRequest.setDefaultCapable(true);
  this.getRootPane().setDefaultButton(bSubmitRequest);
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-makeproject

public boolean showMe() {
  String title = NbBundle.getMessage(RerunArguments.class, "RerunArguments.title.text"); // NOI18N
  DialogDescriptor dd = new DialogDescriptor(this, title);
  dd.setOptionType(NotifyDescriptor.OK_CANCEL_OPTION);
  JButton run = new JButton(NbBundle.getMessage(RerunArguments.class, "LBL_run_advanced_run")); // NOI18N
  run.setDefaultCapable(true);
  JButton cancel = new JButton(NbBundle.getMessage(RerunArguments.class, "LBL_run_advanced_cancel")); // NOI18N
  dd.setOptions(new Object[] {run, cancel});
  dd.setModal(true);
  Object result = DialogDisplayer.getDefault().notify(dd);
  if (result.equals(run)) {
    for(ProjectActionEvent event : paes) {
      if (event.getType() == ProjectActionEvent.PredefinedType.RUN ||
        event.getType() == ProjectActionEvent.PredefinedType.DEBUG ||
        event.getType() == ProjectActionEvent.PredefinedType.DEBUG_STEPINTO) {
        event.getProfile().getRunCommand().setValue(argumentsField.getText());
        break;
      }
    }
    return true;
  }
  return false;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-profiler

/**
 * Create an informational report about the results of a command.
 *
 * @param shortMsg the short message object
 * @param detailsMsg the details message object
 * @see org.openide.NotifyDescriptor#NotifyDescriptor
 */
public MessageWithDetails(final Object shortMsg, final Object detailsMsg, final boolean respectParent) {
  super(shortMsg, NotifyDescriptor.getTitleForType(NotifyDescriptor.INFORMATION_MESSAGE));
  this.detailsMsg = detailsMsg;
  showDetailsButton.setDefaultCapable(false);
  setOptions(new Object[] { OK_OPTION });
  setAdditionalOptions(new Object[] { showDetailsButton });
  setLeaf(!respectParent);
}

代码示例来源:origin: pentaho/pentaho-reporting

public ArrayCellEditor() {
 setLayout( new BorderLayout() );
 this.eventListenerList = new EventListenerList();
 ellipsisButton = new EllipsisButton( "..." );
 ellipsisButton.setDefaultCapable( false );
 ellipsisButton.addActionListener( new ExtendedEditorAction() );
 textField = new JTextField();
 textField.setDocument( new NonFilteringPlainDocument() );
 textField.getInputMap().put( Messages.getInstance().getKeyStroke
  ( "PropertyCellEditorWithEllipsis.PopupEditor.Accelerator" ), POPUP_EDITOR );
 textField.getActionMap().put( POPUP_EDITOR, new ExtendedEditorAction() );
 textField.setBorder( BorderFactory.createEmptyBorder() );
 textField.setEditable( false );
 add( textField, BorderLayout.CENTER );
 add( ellipsisButton, BorderLayout.EAST );
 nullable = false;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-profiler

/**
 * Create a report about the results of a command.
 *
 * @param shortMsg     the message object
 * @param detailsMsg the details message object
 * @param messageType the type of message to be displayed
 * @see org.openide.NotifyDescriptor#NotifyDescriptor
 */
public MessageWithDetails(final Object shortMsg, final Object detailsMsg, final int messageType,
             final boolean respectParent) {
  super(shortMsg, NotifyDescriptor.getTitleForType(messageType));
  this.setMessageType(messageType);
  this.detailsMsg = detailsMsg;
  showDetailsButton.setDefaultCapable(false);
  setOptions(new Object[] { OK_OPTION });
  setAdditionalOptions(new Object[] { showDetailsButton });
  setLeaf(!respectParent);
}

相关文章

JButton类方法