List of usage examples for java.awt.event KeyEvent KeyEvent
@SuppressWarnings("deprecation") public KeyEvent(Component source, int id, long when, int modifiers, int keyCode, char keyChar, int keyLocation)
From source file:com.github.fritaly.dualcommander.TabbedPane.java
@Override public void keyPressed(KeyEvent e) { if (e.getSource() == getSelectedComponent()) { final boolean metaDown = (e.getModifiersEx() | KeyEvent.META_DOWN_MASK) == KeyEvent.META_DOWN_MASK; if ((e.getKeyCode() == KeyEvent.VK_T) && metaDown) { // Create a new tab and set to focus on it setSelectedComponent(addBrowserTab(getActiveBrowser().getDirectory())); } else if ((e.getKeyCode() == KeyEvent.VK_W) && metaDown) { if (getTabCount() > 1) { // Close the current tab (only if not the last one) closeActiveBrowserTab(); }//from www . j a v a 2 s . c o m } else if ((e.getKeyCode() >= KeyEvent.VK_1) && (e.getKeyCode() <= KeyEvent.VK_9) && metaDown) { final int index = e.getKeyCode() - KeyEvent.VK_1; if (index <= getTabCount() - 1) { setSelectedIndex(index); } } else { // Propagate event to our listeners processKeyEvent(new KeyEvent(this, e.getID(), e.getWhen(), e.getModifiers(), e.getKeyCode(), e.getKeyChar(), e.getKeyLocation())); } } }
From source file:com.github.fritaly.dualcommander.TabbedPane.java
@Override public void keyReleased(KeyEvent e) { if (e.getSource() == getSelectedComponent()) { // Propagate the event to our listeners processKeyEvent(new KeyEvent(this, e.getID(), e.getWhen(), e.getModifiers(), e.getKeyCode(), e.getKeyChar(), e.getKeyLocation())); }/* w w w . j a v a 2s . c o m*/ }
From source file:com.github.fritaly.dualcommander.TabbedPane.java
@Override public void keyTyped(KeyEvent e) { if (e.getSource() == getSelectedComponent()) { // Propagate the event to our listeners processKeyEvent(new KeyEvent(this, e.getID(), e.getWhen(), e.getModifiers(), e.getKeyCode(), e.getKeyChar(), e.getKeyLocation())); }/*from w w w. ja v a2s .c om*/ }
From source file:com.github.fritaly.dualcommander.DirectoryBrowser.java
@Override public void keyPressed(KeyEvent e) { if (e.getSource() != table) { return;/* w w w .j a v a 2 s.co m*/ } if (e.getKeyCode() == KeyEvent.VK_ENTER) { // What's the current selection ? final List<File> selection = getSelection(); if (selection.size() == 1) { final File selectedFile = selection.iterator().next(); if (selectedFile.isDirectory()) { // Change to the selected directory setDirectory(selectedFile); } } } else if (e.getKeyCode() == KeyEvent.VK_BACK_SPACE) { // Return to the parent directory (if any) final File parentDir = getParentDirectory(); if ((parentDir != null) && parentDir.exists()) { setDirectory(parentDir); } } else { // Propagate event to our listeners processKeyEvent(new KeyEvent(this, e.getID(), e.getWhen(), e.getModifiers(), e.getKeyCode(), e.getKeyChar(), e.getKeyLocation())); } }
From source file:com.github.fritaly.dualcommander.DirectoryBrowser.java
@Override public void keyReleased(KeyEvent e) { if (e.getSource() != table) { return;//w ww . j ava2s. com } // Propagate event to our listeners processKeyEvent(new KeyEvent(this, e.getID(), e.getWhen(), e.getModifiers(), e.getKeyCode(), e.getKeyChar(), e.getKeyLocation())); }
From source file:com.github.fritaly.dualcommander.DirectoryBrowser.java
@Override public void keyTyped(KeyEvent e) { if (e.getSource() != table) { return;/*from w ww .j a v a2 s .c o m*/ } // Propagate event to our listeners processKeyEvent(new KeyEvent(this, e.getID(), e.getWhen(), e.getModifiers(), e.getKeyCode(), e.getKeyChar(), e.getKeyLocation())); }