热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

java.awt.KeyboardFocusManager.getCurrentKeyboardFocusManager()方法的使用及代码示例

本文整理了Java中java.awt.KeyboardFocusManager.getCurrentKeyboardFocusManager()方法的一些代码示例,展示

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

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(focusOwner);
} else {
originalFocusOwner = new WeakReference(component);
}
}

代码示例来源: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);
}

推荐阅读
  • 目录实现效果:实现环境实现方法一:基本思路主要代码JavaScript代码总结方法二主要代码总结方法三基本思路主要代码JavaScriptHTML总结实 ... [详细]
  • Java容器中的compareto方法排序原理解析
    本文从源码解析Java容器中的compareto方法的排序原理,讲解了在使用数组存储数据时的限制以及存储效率的问题。同时提到了Redis的五大数据结构和list、set等知识点,回忆了作者大学时代的Java学习经历。文章以作者做的思维导图作为目录,展示了整个讲解过程。 ... [详细]
  • 自动轮播,反转播放的ViewPagerAdapter的使用方法和效果展示
    本文介绍了如何使用自动轮播、反转播放的ViewPagerAdapter,并展示了其效果。该ViewPagerAdapter支持无限循环、触摸暂停、切换缩放等功能。同时提供了使用GIF.gif的示例和github地址。通过LoopFragmentPagerAdapter类的getActualCount、getActualItem和getActualPagerTitle方法可以实现自定义的循环效果和标题展示。 ... [详细]
  • 标题: ... [详细]
  • 闭包一直是Java社区中争论不断的话题,很多语言都支持闭包这个语言特性,闭包定义了一个依赖于外部环境的自由变量的函数,这个函数能够访问外部环境的变量。本文以JavaScript的一个闭包为例,介绍了闭包的定义和特性。 ... [详细]
  • 本文介绍了Python爬虫技术基础篇面向对象高级编程(中)中的多重继承概念。通过继承,子类可以扩展父类的功能。文章以动物类层次的设计为例,讨论了按照不同分类方式设计类层次的复杂性和多重继承的优势。最后给出了哺乳动物和鸟类的设计示例,以及能跑、能飞、宠物类和非宠物类的增加对类数量的影响。 ... [详细]
  • Week04面向对象设计与继承学习总结及作业要求
    本文总结了Week04面向对象设计与继承的重要知识点,包括对象、类、封装性、静态属性、静态方法、重载、继承和多态等。同时,还介绍了私有构造函数在类外部无法被调用、static不能访问非静态属性以及该类实例可以共享类里的static属性等内容。此外,还提到了作业要求,包括讲述一个在网上商城购物或在班级博客进行学习的故事,并使用Markdown的加粗标记和语句块标记标注关键名词和动词。最后,还提到了参考资料中关于UML类图如何绘制的范例。 ... [详细]
  • 重入锁(ReentrantLock)学习及实现原理
    本文介绍了重入锁(ReentrantLock)的学习及实现原理。在学习synchronized的基础上,重入锁提供了更多的灵活性和功能。文章详细介绍了重入锁的特性、使用方法和实现原理,并提供了类图和测试代码供读者参考。重入锁支持重入和公平与非公平两种实现方式,通过对比和分析,读者可以更好地理解和应用重入锁。 ... [详细]
  • 本文介绍了RxJava在Android开发中的广泛应用以及其在事件总线(Event Bus)实现中的使用方法。RxJava是一种基于观察者模式的异步java库,可以提高开发效率、降低维护成本。通过RxJava,开发者可以实现事件的异步处理和链式操作。对于已经具备RxJava基础的开发者来说,本文将详细介绍如何利用RxJava实现事件总线,并提供了使用建议。 ... [详细]
  • PHP反射API的功能和用途详解
    本文详细介绍了PHP反射API的功能和用途,包括动态获取信息和调用对象方法的功能,以及自动加载插件、生成文档、扩充PHP语言等用途。通过反射API,可以获取类的元数据,创建类的实例,调用方法,传递参数,动态调用类的静态方法等。PHP反射API是一种内建的OOP技术扩展,通过使用Reflection、ReflectionClass和ReflectionMethod等类,可以帮助我们分析其他类、接口、方法、属性和扩展。 ... [详细]
  • GetWindowLong函数
    今天在看一个代码里头写了GetWindowLong(hwnd,0),我当时就有点费解,靠,上网搜索函数原型说明,死活找不到第 ... [详细]
  • JavaSE笔试题-接口、抽象类、多态等问题解答
    本文解答了JavaSE笔试题中关于接口、抽象类、多态等问题。包括Math类的取整数方法、接口是否可继承、抽象类是否可实现接口、抽象类是否可继承具体类、抽象类中是否可以有静态main方法等问题。同时介绍了面向对象的特征,以及Java中实现多态的机制。 ... [详细]
  • PHP中的单例模式与静态变量的区别及使用方法
    本文介绍了PHP中的单例模式与静态变量的区别及使用方法。在PHP中,静态变量的存活周期仅仅是每次PHP的会话周期,与Java、C++不同。静态变量在PHP中的作用域仅限于当前文件内,在函数或类中可以传递变量。本文还通过示例代码解释了静态变量在函数和类中的使用方法,并说明了静态变量的生命周期与结构体的生命周期相关联。同时,本文还介绍了静态变量在类中的使用方法,并通过示例代码展示了如何在类中使用静态变量。 ... [详细]
  • 本文介绍了Web学习历程记录中关于Tomcat的基本概念和配置。首先解释了Web静态Web资源和动态Web资源的概念,以及C/S架构和B/S架构的区别。然后介绍了常见的Web服务器,包括Weblogic、WebSphere和Tomcat。接着详细讲解了Tomcat的虚拟主机、web应用和虚拟路径映射的概念和配置过程。最后简要介绍了http协议的作用。本文内容详实,适合初学者了解Tomcat的基础知识。 ... [详细]
  • 篇首语:本文由编程笔记#小编为大家整理,主要介绍了10分钟了解Android的事件分发相关的知识,希望对你有一定的参考价值。什么是事件分发?大家 ... [详细]
author-avatar
平凡数码广场
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有