当前位置: 首页>>代码示例>>Java>>正文


Java Component.addKeyListener方法代码示例

本文整理汇总了Java中java.awt.Component.addKeyListener方法的典型用法代码示例。如果您正苦于以下问题:Java Component.addKeyListener方法的具体用法?Java Component.addKeyListener怎么用?Java Component.addKeyListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.Component的用法示例。


在下文中一共展示了Component.addKeyListener方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: EventBinding

import java.awt.Component; //导入方法依赖的package包/类
/**
 * Creates a new Binding.
 * @param c the JOGLUI canvas
 * @param d the FengGUI Display
 */
public EventBinding(Component c, Display d) 
{
    display = d;
    
    // makes FengGUI listen to tab keys
    // http://answers.google.com/answers/threadview?id=126916
    c.setFocusTraversalKeysEnabled(false);
    
    c.addMouseListener(this);
    c.addMouseMotionListener(this);
    c.addMouseWheelListener(this);
    c.addKeyListener(this);
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:19,代码来源:EventBinding.java

示例2: setKeyListener

import java.awt.Component; //导入方法依赖的package包/类
public static Component setKeyListener(Component c, KeyListener kl) {
    if(c.getKeyListeners().length > 0) {
        for(KeyListener g : c.getKeyListeners()) {
            c.removeKeyListener(g);
        }
    }
    c.addKeyListener(kl);
    return c;
}
 
开发者ID:Panzer1119,项目名称:JAddOn,代码行数:10,代码来源:JUtils.java

示例3: subscribeActual

import java.awt.Component; //导入方法依赖的package包/类
@Override
protected void subscribeActual(Observer<? super KeyEvent> observer) {
    Component w = widget;

    KeyEventConsumer aec = new KeyEventConsumer(observer, w);
    observer.onSubscribe(aec);

    w.addKeyListener(aec);
    if (aec.get() == null) {
        w.removeKeyListener(aec);
    }
}
 
开发者ID:akarnokd,项目名称:RxJava2Swing,代码行数:13,代码来源:KeyEventObservable.java

示例4: addDeleteListener

import java.awt.Component; //导入方法依赖的package包/类
private Component addDeleteListener(Component comp) {
//            System.out.println("");
//            System.out.println("comp="+comp);
//            if (comp.getClass() == sun.swing.FilePane.class) return comp;

                if (comp instanceof Container) {
//                System.out.println(comp+"\n");
//                comp.addMouseListener(new MouseAdapter(){
//                    public void mouseEntered(MouseEvent e){
//                        System.out.println("mouse entered: "+e);
//                    }
//                });
//                    if(comp.getClass().getEnclosingClass()==sun.swing.FilePane.class){
//                        System.out.println("******adding keyListener to "+comp);
                    comp.addKeyListener(new KeyAdapter() {

                        @Override
						public void keyReleased(KeyEvent e) {
                            if (e.getKeyCode() == KeyEvent.VK_DELETE) {
//                                    System.out.println("delete key typed from "+e.getSource());
                                deleteFile();
                            }
                        }
                    });
//                    }
                    Component[] components = ((Container) comp).getComponents();
                    for (Component component2 : components) {
                        Component child = addDeleteListener(component2);
                        if (child != null) {
                            return child;
                        }
                    }
                }
                return null;
            }
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:36,代码来源:MotionViewer.java

示例5: addDeleteListener

import java.awt.Component; //导入方法依赖的package包/类
private Component addDeleteListener(Component comp) {
//            System.out.println("");
//            System.out.println("comp="+comp);
//            if (comp.getClass() == sun.swing.FilePane.class) return comp;
            if (comp instanceof Container) {
//                System.out.println(comp+"\n");
//                comp.addMouseListener(new MouseAdapter(){
//                    public void mouseEntered(MouseEvent e){
//                        System.out.println("mouse entered: "+e);
//                    }
//                });
                // if this is a known filepane class, then add a key listener for deleting log files.
                // may need to remove this in future release of java and
                //find a portable way to detect we are in the FilePane
//                    if(comp.getClass().getEnclosingClass()==sun.swing.FilePane.class) {
//                        System.out.println("******adding keyListener to "+comp);
                comp.addKeyListener(new KeyAdapter() {
                    @Override
                    public void keyReleased(KeyEvent e) {
                        if (e.getKeyCode() == KeyEvent.VK_DELETE) {
//                                    System.out.println("delete key typed from "+e.getSource());
                            deleteFile();
                        }
                    }
                });
//                    }
                Component[] components = ((Container) comp).getComponents();
                for (Component component : components) {
                    Component child = addDeleteListener(component);
                    if (child != null) {
                        return child;
                    }
                }
            }
            return null;
        }
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:37,代码来源:AEPlayer.java

示例6: addKeyListeners

import java.awt.Component; //导入方法依赖的package包/类
/**
 *  Adds a feature to the KeyListeners attribute of the FileChooserFixer object
 *
 * @param  c  The feature to be added to the KeyListeners attribute
 */
private void addKeyListeners(Container c) {
	for (int i = 0; i < c.getComponentCount(); i++) {
		Component d = c.getComponent(i);
		if (d instanceof Container) {
			addKeyListeners((Container) d);
		}
		d.addKeyListener(this);
	}
}
 
开发者ID:SarutaSan72,项目名称:Yass,代码行数:15,代码来源:FileChooserFixer.java

示例7: createAndShowGUI

import java.awt.Component; //导入方法依赖的package包/类
private static void createAndShowGUI() {
    f = new JFrame();

    final Component component = new JTextField();
    component.addKeyListener(new MyKeyListener());

    f.add(component);
    f.setSize(300, 300);
    f.setLocationRelativeTo(null);
    f.setAlwaysOnTop(true);
    f.setVisible(true);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:MouseModifiersInKeyEvent.java


注:本文中的java.awt.Component.addKeyListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。