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

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

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

JButton.grabFocus介绍

暂无

代码示例

代码示例来源:origin: de.dfki.mary/marytts-transcription

  1. public void run() {
  2. startUpHelpDialog.toFront();
  3. closeHelp.grabFocus();
  4. }
  5. });

代码示例来源:origin: de.dfki.mary/marytts-transcription

  1. private void helpMenuItemActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_helpMenuItemActionPerformed
  2. try {
  3. htmlEditor.setContentType("text/html; charset=UTF-8");
  4. htmlEditor
  5. .read(new InputStreamReader(TranscriptionGUI.class.getResourceAsStream("instructions.html"), "UTF-8"), null);
  6. htmlEditor.setPreferredSize(new Dimension(500, 400));
  7. htmlEditor.setEditable(true);
  8. htmlEditor.updateUI();
  9. startUpHelpDialog.setSize(new Dimension(700, 500));
  10. startUpHelpDialog.repaint();
  11. closeHelp.grabFocus();
  12. startUpHelpDialog.setVisible(true);
  13. startUpHelpDialog.repaint();
  14. } catch (IOException e) {
  15. e.printStackTrace();
  16. System.out.println("Could not read file : " + e.getMessage());
  17. }
  18. }// GEN-LAST:event_helpMenuItemActionPerformed

代码示例来源:origin: stackoverflow.com

  1. b.grabFocus();
  2. pack();

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

  1. private static ClientUtils.SourceCodeSelection[] performDisplay(final RootMethodsPanel rm) {
  2. final DialogDescriptor dd = new DialogDescriptor(rm, Bundle.RootMethodsPanel_SpecifyRootMethodsDialogCaption());
  3. final Dialog d = DialogDisplayer.getDefault().createDialog(dd);
  4. if (rm.addFromJarButton.isEnabled()) {
  5. rm.addFromJarButton.grabFocus();
  6. }
  7. d.setVisible(true);
  8. if (dd.getValue() == DialogDescriptor.OK_OPTION) {
  9. ClientUtils.SourceCodeSelection[] ret = new ClientUtils.SourceCodeSelection[rm.selectedRoots.size()];
  10. rm.selectedRoots.toArray(ret);
  11. return ret;
  12. }
  13. return null;
  14. }

代码示例来源:origin: uk.ac.gate.plugins/tools

  1. @Override
  2. public void mouseClicked(MouseEvent e) {
  3. if (! (e.getSource() instanceof JButton))
  4. return;
  5. JButton source = (JButton) e.getSource();
  6. //check if CTRL or Shift is pressed and if not, clear the selection
  7. if ((! (e.isControlDown() || e.isShiftDown()))
  8. && SwingUtilities.isLeftMouseButton(e))
  9. clearSelection();
  10. //and select the current node
  11. if (SwingUtilities.isLeftMouseButton(e))
  12. //if (e.getModifiers() == e.BUTTON1_MASK)
  13. selectNode(e);
  14. //only repspond to right-clicks here by displaying the popup
  15. if (SwingUtilities.isRightMouseButton(e)) {
  16. //if button not in focus, grad the focus and select it!
  17. if ( source.getBackground() != selectedNodeColor ) {
  18. source.grabFocus();
  19. source.doClick();
  20. selectNode(e);
  21. }
  22. //Out.println(e.getComponent().getClass() + " right-clicked!");
  23. showRightClickPopup(e);
  24. } //end of right-click processing
  25. }// public void mouseClicked(MouseEvent e)

相关文章

JButton类方法