javax.swing.text.JTextComponent.requestFocusInWindow()方法的使用及代码示例

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

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

JTextComponent.requestFocusInWindow介绍

暂无

代码示例

代码示例来源:origin: bobbylight/RSyntaxTextArea

/**
 * Overridden to also focus the text component on right mouse clicks.
 *
 * @param e The mouse event.
 */
@Override
public void mousePressed(MouseEvent e) {
  super.mousePressed(e);
  if (!e.isConsumed() && SwingUtilities.isRightMouseButton(e)) {
    JTextComponent c = getComponent();
    if (c!=null && c.isEnabled() && c.isRequestFocusEnabled()) {
      c.requestFocusInWindow();
    }
  }
}

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

public void refocus() {
if (watchText != null)
  watchText.requestFocusInWindow();
}

代码示例来源:origin: jcoplien/trygve

protected void requestFocus() {
   myComponent_.requestFocusInWindow();
}

代码示例来源:origin: nz.ac.waikato.cms.weka.thirdparty/bounce

public void mouseClicked(MouseEvent e) {
    FoldingMargin.this.editor.requestFocusInWindow();
    toggleFold(getLineNumber(e.getY()));
  }
});

代码示例来源:origin: nz.ac.waikato.cms.weka.thirdparty/bounce

/**
 * Receives all mouse-click events in the margin.
 * 
 * @param event the mouse event.
 */
protected void mouseClicked(MouseEvent event) {
  selectLineForOffset(event.getY());
  LineNumberMargin.this.editor.requestFocusInWindow();
}

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

public class SelectAll extends TextAction
{
  public SelectAll()
  {
    super("Select All");
  }

  public void actionPerformed(ActionEvent e)
  {
    JTextComponent component = getFocusedComponent();
    component.selectAll();
    component.requestFocusInWindow();
  }
}

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

class SelectAll extends TextAction
{
  public SelectAll()
  {
    super("Select All");
  }

  public void actionPerformed(ActionEvent e)
  {
    JTextComponent component = getFocusedComponent();
    component.selectAll();
    component.requestFocusInWindow();
  }
}

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

static class SelectAll extends TextAction
{
  public SelectAll()
  {
    super("Select All");
  }

  public void actionPerformed(ActionEvent e)
  {
    JTextComponent component = getFocusedComponent();
    component.selectAll();
    component.requestFocusInWindow();
  }
}

代码示例来源:origin: jcbvm/i18n-editor

private void showPopupMenu(MouseEvent e) {
    if (!e.isPopupTrigger() || !parent.isEditable()) {
      return;
    }
    parent.requestFocusInWindow();
    menu.show(parent, e.getX(), e.getY());
  }
}

代码示例来源:origin: raydac/netbeans-mmd-plugin

@Override
 public void actionPerformed(@Nonnull final ActionEvent e) {
  final JTextComponent component = getFocusedComponent();
  if (component != null) {
   ((JTextComponent) component).selectAll();
   component.requestFocusInWindow();
  }
 }
}

代码示例来源:origin: RPTools/maptool

public void actionPerformed(ActionEvent e) {
    String selectedText = source.getSelectedText();
    if (selectedText == null) {
      selectedText = source.getText();
    }
    // TODO: Combine this with the code in MacroButton
    JTextComponent commandArea = MapTool.getFrame().getCommandPanel().getCommandTextArea();
    commandArea.setText(commandArea.getText() + selectedText);
    commandArea.requestFocusInWindow();
  }
});

代码示例来源:origin: khuxtable/seaglass

/**
 * DOCUMENT ME!
 */
private void doPopup() {
  if (findPopup != null) {
    JTextComponent c = getComponent();
    findPopup.pack();
    // The "-1" just snugs us up a bit under the text field.
    findPopup.show(c, 0, c.getHeight() - 1);
    // Set focus back to the text field.
    // TODO Fix caret positioning, selection, etc.
    c.requestFocusInWindow();
  }
}

代码示例来源:origin: io.ultreia.java4all.i18n/i18n-editor

@Override
  public final void actionPerformed(ActionEvent e) {
    Optional<LocalizedItemUI> focus = itemComponent.getPanel().getFocus();
    if (doAction(itemComponent)) {
      focus.ifPresent(f -> f.getEditor().requestFocusInWindow());
    }
  }
}

代码示例来源:origin: gaborbata/jpass

private void showPopupMenu(MouseEvent e) {
  if (e.isPopupTrigger() && e.getSource() instanceof JTextComponent) {
    JTextComponent textComponent = (JTextComponent) e.getSource();
    if (textComponent.isEnabled() && (textComponent.hasFocus() || textComponent.requestFocusInWindow())) {
      this.cutItem.setEnabled(TextComponentActionType.CUT.getAction().isEnabled(textComponent));
      this.copyItem.setEnabled(TextComponentActionType.COPY.getAction().isEnabled(textComponent));
      this.pasteItem.setEnabled(TextComponentActionType.PASTE.getAction().isEnabled(textComponent));
      this.deleteItem.setEnabled(TextComponentActionType.DELETE.getAction().isEnabled(textComponent));
      this.clearAllItem.setEnabled(TextComponentActionType.CLEAR_ALL.getAction().isEnabled(textComponent));
      this.selectAllItem.setEnabled(TextComponentActionType.SELECT_ALL.getAction().isEnabled(textComponent));
      this.popup.show(e.getComponent(), e.getX(), e.getY());
    }
  }
}

代码示例来源:origin: de.sciss/syntaxpane

private void jBtnNextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnNextActionPerformed
  try {
    updateFinder();
    if (!dsd.doFindNext(textComponent)) {
      dsd.msgNotFound(textComponent);
    }
    textComponent.requestFocusInWindow();
  } catch (PatternSyntaxException ex) {
    showRegexpError(ex);
  }
}//GEN-LAST:event_jBtnNextActionPerformed

代码示例来源:origin: org.apache.cayenne.modeler/cayenne-modeler

@Override
public void redo() throws CannotRedoException {
  restoreSelections();
  if (canRedo()) {
    super.redo();
  } else {
    die();
  }
  editor.requestFocusInWindow();
}

代码示例来源:origin: RPTools/maptool

public void actionPerformed(ActionEvent e) {
    String selectedText = source.getSelectedText();
    if (selectedText == null) {
      selectedText = source.getText();
    }
    // TODO: Combine this with the code in MacroButton
    JTextComponent commandArea = MapTool.getFrame().getCommandPanel().getCommandTextArea();
    commandArea.setText("/emit " + selectedText);
    commandArea.requestFocusInWindow();
    MapTool.getFrame().getCommandPanel().commitCommand();
  }
});

代码示例来源:origin: de.sciss/jsyntaxpane

private void jBtnNextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnNextActionPerformed
  try {
    updateFinder();
    if (!dsd.doFindNext(textComponent)) {
      dsd.msgNotFound(textComponent);
    }
    textComponent.requestFocusInWindow();
  } catch (PatternSyntaxException ex) {
    showRegexpError(ex);
  }
}//GEN-LAST:event_jBtnNextActionPerformed

代码示例来源:origin: RPTools/maptool

public void actionPerformed(ActionEvent e) {
    JTextComponent commandArea = MapTool.getFrame().getCommandPanel().getCommandTextArea();
    if (!AppUtil.playerOwns(tokenUnderMouse)) {
      return;
    }
    commandArea.setText("/im " + tokenUnderMouse.getId());
    MapTool.getFrame().getCommandPanel().commitCommand();
    commandArea.requestFocusInWindow();
  }
}

代码示例来源:origin: org.apache.cayenne.modeler/cayenne-modeler

public void undo() throws CannotUndoException {
  restoreSelections();
  listener.finishCurrentEdit();
  if (canUndo()) {
    super.undo();
  } else {
    die();
  }
  if (adapter != null) {
    adapter.updateModel();
  }
  editor.requestFocusInWindow();
  editor.selectAll();
}

相关文章

JTextComponent类方法