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


Java KeyboardFocusManager.addKeyEventDispatcher方法代码示例

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


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

示例1: install

import java.awt.KeyboardFocusManager; //导入方法依赖的package包/类
public static synchronized void install() {
    if(installed) {
        return;
    }
    
    ShortcutAndMenuKeyEventProcessor instance = getDefault();
    
    KeyboardFocusManager keyboardFocusManager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
    keyboardFocusManager.addKeyEventDispatcher(instance);
    keyboardFocusManager.addKeyEventPostProcessor(instance);
    // #63252: Disable focus traversal functionality of Ctrl+Tab and Ctrl+Shift+Tab,
    // to allow our own document switching (RecentViewListAction)
    defaultForward = keyboardFocusManager.getDefaultFocusTraversalKeys(
                        KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS);
    defaultBackward = keyboardFocusManager.getDefaultFocusTraversalKeys(
                        KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS);
    keyboardFocusManager.setDefaultFocusTraversalKeys(
        KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS,
        Collections.singleton(AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_TAB, 0))
    );                
    keyboardFocusManager.setDefaultFocusTraversalKeys(
        KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS,
        Collections.singleton(AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_TAB, KeyEvent.SHIFT_DOWN_MASK))
    );                
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:ShortcutAndMenuKeyEventProcessor.java

示例2: MapEventHandler

import java.awt.KeyboardFocusManager; //导入方法依赖的package包/类
/**
 * Creates a new instance of MapEventHandler
 *
 * @param mapComponent The MapComponent for which this MapEventHandler
 * receives events.
 */
public MapEventHandler(MapComponent mapComponent) {
    this.mapComponent = mapComponent;
    mapComponent.addMouseListener(this);
    mapComponent.addMouseMotionListener(this);
    mapComponent.addMouseWheelListener(this);

    KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
    kfm.addKeyEventDispatcher(this);
    mapTool = new SelectionTool(mapComponent);
}
 
开发者ID:berniejenny,项目名称:MapAnalyst,代码行数:17,代码来源:MapEventHandler.java

示例3: initializeJFrame

import java.awt.KeyboardFocusManager; //导入方法依赖的package包/类
private void initializeJFrame(int nrows, int ncols) {
	_nrows = nrows;
	_ncols = ncols;
	
    setTitle("2048");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setLayout(new GridLayout(nrows, ncols));
    
    ImageIcon icon = new ImageIcon("images/button_background.png");
    
    _buttons = new JButton[_nrows][_ncols];
    for (int i = 0; i < nrows; i++) {
    	for (int j = 0; j < ncols; j++) {
    		//_buttons[i][j] = new JButton(String.format("%d", values[i][j]));
    		_buttons[i][j] = new JButton(String.format("%d,%d", i,j));
    		_buttons[i][j].setIcon(icon);
    		_buttons[i][j].setHorizontalTextPosition(SwingConstants.CENTER);
    		_buttons[i][j].setFont(new Font("Arial", Font.PLAIN, 40));
    		add(_buttons[i][j]);
    	}
    }
    setResizable(false);
    setSize(1000, 1000);
    pack();
    setVisible(true);
    setFocusable(true);
	setFocusTraversalKeysEnabled(false);
    //add(new JTextField());
    KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
    manager.addKeyEventDispatcher(new MyDispatcher(this));
}
 
开发者ID:lukealba,项目名称:2048-java-swing,代码行数:32,代码来源:Main.java

示例4: startTransform

import java.awt.KeyboardFocusManager; //导入方法依赖的package包/类
void startTransform(){
    //Create and instance of the analysis class
    guiInput = new Hough_Circle();
    
    KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
    manager.addKeyEventDispatcher(new MyDispatcher());
    
    //Add an action listener to the status to allow for GUI to be updated
    //Code modified from: http://www.javacreed.com/swing-worker-example/

    guiInput.addPropertyChangeListener((final PropertyChangeEvent event) -> {
        switch (event.getPropertyName()) {
            
            //If event has progress flag, update progress bar
            case "progress":
                barString = guiInput.getStatus();
                if(isGUI){
                    guiProgressBar.setIndeterminate(false);
                    guiProgressBar.setValue((Integer) event.getNewValue()); 
                    guiProgressBar.setString(barString);
                }
                break;
                
            //if event has state flag, it indicates thread completion status
            case "state":
                switch ((StateValue) event.getNewValue()) {
                    
                    //If worker thread is done, then clear out progress indicators and set button to "OK"
                    case DONE:
                        IJ.showProgress(0);
                        if(isGUI){
                            guiProgressBar.setVisible(false);
                            guiOKButton.setText("OK");
                        }
                        analysisStarted = false;
                        IJ.showStatus("Analysis complete...");
                        break;
                        
                    //If worker has just started, set progress to indetertminate, to let user know plugin is active
                    case STARTED:
                        if(isGUI){
                            guiProgressBar.setVisible(true);
                            guiProgressBar.setIndeterminate(true);
                            guiProgressBar.setString("Starting Transform...");
                        }
                        break;
                    case PENDING:
                        if(isGUI){
                            guiProgressBar.setVisible(true);
                            guiProgressBar.setIndeterminate(true);
                        }
                        break;
                }
                break;
        }
    });

    //Start the background transform by sending the GUI variables to the transform
    guiInput.setParameters(radiusMin, radiusMax, radiusInc, minCircles, maxCircles, thresholdRatio, resolution, ratio, searchBand, 
            searchRadius, reduce, local, houghSeries, showCircles, showID, showScores, results, isGUI);

    //Start the analysis on a separate thread so the GUI stays free.
    guiInput.execute();
}
 
开发者ID:Llamero,项目名称:Local_Hough_Circle,代码行数:65,代码来源:Hough_GUI.java


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