本文整理了Java中java.awt.KeyboardFocusManager.getCurrentKeyboardFocusManager()
方法的一些代码示例,展示了KeyboardFocusManager.getCurrentKeyboardFocusManager()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。KeyboardFocusManager.getCurrentKeyboardFocusManager()
方法的具体详情如下:
包路径:java.awt.KeyboardFocusManager
类名称:KeyboardFocusManager
方法名:getCurrentKeyboardFocusManager
[英]Returns the current KeyboardFocusManager instance for the calling thread's context.
[中]返回调用线程上下文的当前KeyboardFocusManager实例。
代码示例来源:origin: stanfordnlp/CoreNLP
public TransferActionListener() {
KeyboardFocusManager manager = KeyboardFocusManager.
getCurrentKeyboardFocusManager();
manager.addPropertyChangeListener("permanentFocusOwner", this);
}
代码示例来源:origin: org.netbeans.api/org-openide-filesystems
/**
* Tries to find an appropriate component to parent the file chooser to
* when showing a dialog.
* @return this
*/
private Component findDialogParent() {
Component parent = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
if (parent == null) {
parent = KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow();
}
if (parent == null) {
Frame[] f = Frame.getFrames();
parent = f.length == 0 ? null : f[f.length - 1];
}
return parent;
}
代码示例来源:origin: JetBrains/ideavim
final SecondaryLoop loop = systemQueue.createSecondaryLoop();
KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(new KeyEventDispatcher() {
@Override
public boolean dispatchKeyEvent(KeyEvent e) {
代码示例来源:origin: stackoverflow.com
KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(new KeyEventDispatcher() {
代码示例来源:origin: org.netbeans.api/org-openide-util
/**
* Finds out the monitor where the user currently has the input focus.
* This method is usually used to help the client code to figure out on
* which monitor it should place newly created windows/frames/dialogs.
*
* @return the GraphicsConfiguration of the monitor which currently has the
* input focus
*/
private static GraphicsConfiguration getCurrentGraphicsConfiguration() {
Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
if (focusOwner != null) {
Window w = SwingUtilities.getWindowAncestor(focusOwner);
if (w != null) {
return w.getGraphicsConfiguration();
} else {
//#217737 - try to find the main window which could be placed in secondary screen
for( Frame f : Frame.getFrames() ) {
if( "NbMainWindow".equals(f.getName())) { //NOI18N
return f.getGraphicsConfiguration();
}
}
}
}
return GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
}
代码示例来源:origin: stackoverflow.com
addField("Phone:");
addField("Email Id:");
KeyboardFocusManager.getCurrentKeyboardFocusManager()
.addPropertyChangeListener("permanentFocusOwner",
new FocusDrivenScroller(panel));
代码示例来源:origin: stackoverflow.com
getCurrentKeyboardFocusManager().focusNextComponent();
getCurrentKeyboardFocusManager().focusPreviousComponent();
KeyboardFocusManager.getCurrentKeyboardFocusManager();
manager.focusNextComponent();
KeyboardFocusManager.getCurrentKeyboardFocusManager();
manager.focusPreviousComponent();
代码示例来源:origin: JetBrains/ideavim
@Override
public boolean dispatchKeyEvent(KeyEvent e) {
final KeyStroke stroke;
if (e.getID() == KeyEvent.KEY_RELEASED) {
stroke = KeyStroke.getKeyStrokeForEvent(e);
if (!StringHelper.isCloseKeyStroke(stroke) && stroke.getKeyCode() != KeyEvent.VK_ENTER) {
return true;
}
} else if (e.getID() == KeyEvent.KEY_TYPED) {
stroke = KeyStroke.getKeyStrokeForEvent(e);
} else {
return true;
}
if (!processor.process(stroke)) {
KeyboardFocusManager.getCurrentKeyboardFocusManager().removeKeyEventDispatcher(this);
loop.exit();
}
return true;
}
});
代码示例来源:origin: ron190/jsql-injection
/**
* Select all textfield content when focused.
*/
public static void addTextFieldShortcutSelectAll() {
KeyboardFocusManager.getCurrentKeyboardFocusManager().addPropertyChangeListener(
"permanentFocusOwner",
propertyChangeEvent -> {
if (propertyChangeEvent.getNewValue() instanceof JTextField) {
SwingUtilities.invokeLater(() -> {
JTextField textField = (JTextField) propertyChangeEvent.getNewValue();
textField.selectAll();
});
}
}
);
}
代码示例来源:origin: org.netbeans.api/org-openide-awt
void setOriginalFocusOwner() {
Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
if (focusOwner != null && component.isAncestorOf(focusOwner)) {
originalFocusOwner = new WeakReference
} else {
originalFocusOwner = new WeakReference
}
}
代码示例来源:origin: winder/Universal-G-Code-Sender
@Override
public void keyReleased(KeyEvent event) {
JTextField field = ((JTextField) event.getComponent());
if (event.getKeyCode() == KeyEvent.VK_ENTER) {
try {
backend.setWorkPositionUsingExpression(axis, field.getText());
} catch (Exception e) {
logger.log(Level.INFO, "Couldn't set the work position", e);
}
KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner();
} else if (event.getKeyCode() == KeyEvent.VK_ESCAPE) {
KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner();
}
}
代码示例来源:origin: org.netbeans.api/org-openide-awt
private boolean checkFocused(JComponent c) {
Component focused = KeyboardFocusManager.getCurrentKeyboardFocusManager().getPermanentFocusOwner();
boolean result = c == focused;
if (!result) {
result = c.isAncestorOf(focused);
}
return result;
}
代码示例来源:origin: magefree/mage
public void removeDialog() {
// avoid memory leak of javax.swing.plaf.nimbus.NimbusStyle$CacheKey
KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner();
//this.setVisible(false);
// important to set close before removing the JInternalFrame to avoid memory leaks (http://bugs.java.com/view_bug.do?bug_id=7163808)
try {
this.setClosed(true);
} catch (PropertyVetoException ex) {
java.util.logging.Logger.getLogger(MageDialog.class.getName()).log(Level.SEVERE, "setClosed(false) failed", ex);
}
MageFrame.getDesktop().remove(this);
}
代码示例来源:origin: winder/Universal-G-Code-Sender
private void addKeyboardListener() {
KeyboardFocusManager.getCurrentKeyboardFocusManager()
.addKeyEventDispatcher(new KeyEventDispatcher() {
@Override
代码示例来源:origin: nodebox/nodebox
container.add(innerPanel, BorderLayout.CENTER);
setSize(600, 400);
Window win = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow();
SwingUtils.centerOnScreen(this, win);
代码示例来源:origin: org.netbeans.api/org-openide-util-ui
/**
* Finds out the monitor where the user currently has the input focus.
* This method is usually used to help the client code to figure out on
* which monitor it should place newly created windows/frames/dialogs.
*
* @return the GraphicsConfiguration of the monitor which currently has the
* input focus
*/
private static GraphicsConfiguration getCurrentGraphicsConfiguration() {
Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
if (focusOwner != null) {
Window w = SwingUtilities.getWindowAncestor(focusOwner);
if (w != null) {
return w.getGraphicsConfiguration();
} else {
//#217737 - try to find the main window which could be placed in secondary screen
for( Frame f : Frame.getFrames() ) {
if( "NbMainWindow".equals(f.getName())) { //NOI18N
return f.getGraphicsConfiguration();
}
}
}
}
return GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
}
代码示例来源:origin: magefree/mage
public void removeFrame() {
KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner();
MageFrame.deactivate(this);
MageFrame.getDesktop().remove(this);
}
代码示例来源:origin: ron190/jsql-injection
/**
* Create Alt shortcut to display menubar ; remove menubar when focus is set to a component.
* @param menubar The menubar to display
*/
public static void addShortcut(final Menubar menubar) {
/* Hide Menubar when focusing any component */
KeyboardFocusManager.getCurrentKeyboardFocusManager().addPropertyChangeListener("permanentFocusOwner",
propertyChangeEvent -> SwingUtilities.invokeLater(() -> {
if (
// Fix #40924: NullPointerException on MediatorGui.panelAddressBar()
MediatorGui.panelAddressBar() != null
&& !MediatorGui.panelAddressBar().isAdvanceIsActivated()
) {
menubar.setVisible(false);
}
})
);
/* Show/Hide the Menubar with Alt key (not Alt Graph) */
KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(
new AltKeyEventDispatcher()
);
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
window = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow();
代码示例来源:origin: winder/Universal-G-Code-Sender
public final void init(BackendAPI backend) {
this.backend = backend;
if (backend != null) {
this.backend.addUGSEventListener(this);
this.setEnabled(backend.isConnected());
}
this.addActionListener((ActionEvent evt) -> action(evt));
KeyboardFocusManager.getCurrentKeyboardFocusManager()
.addKeyEventDispatcher(this);
}