當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。