javax.swing.JComponent.requestFocus()方法的使用及代码示例

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

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

JComponent.requestFocus介绍

暂无

代码示例

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

frame.setVisible(true);
frame.getRootPane().setDefaultButton(start);
start.requestFocus();

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

setVisible(true);
jTextField1.selectAll();
jTextField1.requestFocus();
jLabel1.setText("Try again!");
jTextField1.selectAll();
jTextField1.requestFocus();

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

edit.read( br, null );
br.close();
edit.requestFocus();
bw.close();
edit.setText("");
edit.requestFocus();

代码示例来源:origin: org.netbeans.api/org-openide-dialogs

comp.requestFocus();

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

textField.requestFocus();

代码示例来源:origin: org.netbeans.api/org-openide-dialogs

/** Overriden to delegate call to user component.
 */
@Override
public void requestFocus() {
  if ((rightComponent != null) && rightComponent.isDisplayable()) {
    JComponent comp = (JComponent) rightComponent;
    Container rootAnc = comp.getFocusCycleRootAncestor();
    FocusTraversalPolicy policy = rootAnc.getFocusTraversalPolicy();
    Component focus = policy.getComponentAfter(rootAnc, comp);
    if (focus != null) {
      focus.requestFocus();
    } else {
      comp.requestFocus();
    }
  } else {
    super.requestFocus();
  }
}

代码示例来源:origin: kaikramer/keystore-explorer

@Override
  public void run() {
    jpfFirst.requestFocus();
  }
});

代码示例来源:origin: net.java.abeille/abeille

public void windowOpened(WindowEvent we) {
    if (m_initialFocusComponent != null)
      m_initialFocusComponent.requestFocus();
  }
});

代码示例来源:origin: com.jalalkiswani/jk-desktop

@Override
  public void actionPerformed(final ActionEvent e) {
    // call your a method that contains your action code
    comp.requestFocus();
  }
});

代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide

public final void requestFocus() {
  if (inner != null) {
    inner.requestFocus();
  } else {
    super.requestFocus();
  }
}

代码示例来源:origin: org.netbeans.api/org-openide-explorer

/** Overridden to force focus requests to the contained editor
 *  component - setting focus to this component directly will
 *  never be desirable. */
public void requestFocus() {
  if (comp != null) {
    comp.requestFocus();
  }
}

代码示例来源:origin: org.netbeans.api/org-openide-explorer

public final void requestFocus() {
  if (inner != null) {
    inner.requestFocus();
  } else {
    super.requestFocus();
  }
}

代码示例来源:origin: com.jidesoft/jide-oss

public void run() {
    Component c = getDefaultFocusComponent();
    if (c instanceof JComponent) {
      ((JComponent) c).requestFocus(true);
    }
  }
};

代码示例来源:origin: elki-project/elki

@Override
public void addNotify() {
 super.addNotify();
 component.requestFocus();
}

代码示例来源:origin: org.netbeans.api/org-openide-explorer

protected void processFocusEvent(FocusEvent fe) {
  super.processFocusEvent(fe);
  if ((fe.getID() == FocusEvent.FOCUS_GAINED) && (inner != null)) {
    inner.requestFocus();
  }
}

代码示例来源:origin: org.tentackle/tentackle-swing

@Override
public boolean requestFocus(boolean temporary) {
 if (isCellEditorUsage()) {
  return ((JComponent) comp).requestFocus(temporary);
 }
 else  {
  return super.requestFocus(temporary);
 }
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide

protected void processFocusEvent(FocusEvent fe) {
  super.processFocusEvent(fe);
  if (fe.getID() == FocusEvent.FOCUS_GAINED && inner != null) {
    inner.requestFocus();
  }
}

代码示例来源:origin: org.netbeans.api/org-openide-explorer

@Override
  public void run() {
    SheetCellEditor cellEditor = getEditor();
    if( null != cellEditor ) {
      InplaceEditor inplace = cellEditor.getInplaceEditor();
      if( null != inplace && null != inplace.getComponent() ) {
        inplace.getComponent().requestFocus();
      }
    }
  }
});

代码示例来源:origin: org.nuiton.jaxx/jaxx-application-swing

@Override
  public void hierarchyChanged(HierarchyEvent e) {
    JComponent component = getComponentToFocus();
    if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) > 0
      && e.getChanged().isShowing()
      && component != null) {
      component.requestFocus();
    }
  }
});

代码示例来源:origin: antlr/intellij-plugin-v4

public void jumpToGrammarPosition(Project project, int start) {
  final ANTLRv4PluginController controller = ANTLRv4PluginController.getInstance(project);
  if ( controller==null ) return;
  final Editor grammarEditor = controller.getEditor(previewState.grammarFile);
  if ( grammarEditor==null ) return;
  CaretModel caretModel = grammarEditor.getCaretModel();
  caretModel.moveToOffset(start);
  ScrollingModel scrollingModel = grammarEditor.getScrollingModel();
  scrollingModel.scrollToCaret(ScrollType.MAKE_VISIBLE);
  grammarEditor.getContentComponent().requestFocus();
}

相关文章

JComponent类方法