List of usage examples for java.awt KeyboardFocusManager BACKWARD_TRAVERSAL_KEYS
int BACKWARD_TRAVERSAL_KEYS
To view the source code for java.awt KeyboardFocusManager BACKWARD_TRAVERSAL_KEYS.
Click Source Link
From source file:Main.java
public static void main(String[] argv) throws Exception { Set<AWTKeyStroke> set = new HashSet<AWTKeyStroke>(); KeyboardFocusManager.getCurrentKeyboardFocusManager() .setDefaultFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, set); }
From source file:Main.java
public static void main(String[] argv) throws Exception { Set<AWTKeyStroke> set = new HashSet<AWTKeyStroke>(KeyboardFocusManager.getCurrentKeyboardFocusManager() .getDefaultFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS)); set.add(KeyStroke.getKeyStroke("F3")); KeyboardFocusManager.getCurrentKeyboardFocusManager() .setDefaultFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, set); }
From source file:Main.java
/** * Disables the forward and backward focus traversal keys on the given * component.// w w w .j a v a 2 s . c o m */ public static void disableFocusTraversal(Component c) { Set<AWTKeyStroke> emptySet = Collections.emptySet(); c.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, emptySet); c.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, emptySet); }
From source file:Main.java
public static void setTabFocusTraversalKeys(final JComponent component) { component.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, new HashSet<AWTKeyStroke>(Arrays.asList(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0)))); component.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, new HashSet<AWTKeyStroke>( Arrays.asList(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, KeyEvent.SHIFT_DOWN_MASK)))); }
From source file:Main.java
/** * install focus forward and backward//from ww w . ja va 2 s.c om */ public static void installDefaultFocusHandling(Container c) { // focus TAB HashSet<KeyStroke> set = new HashSet<KeyStroke>(1); set.add(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0)); c.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, set); // focus shift-TAB set = new HashSet<KeyStroke>(1); set.add(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_MASK)); c.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, set); // make input map WHEN_FOCUSED non-empty for Focus Traversal policy to work // correctly if (c instanceof JComponent) { JComponent jc = (JComponent) c; InputMap inputMapWhenFocused = jc.getInputMap(JComponent.WHEN_FOCUSED); if (inputMapWhenFocused.size() == 0) { inputMapWhenFocused.put(KeyStroke.getKeyStroke(KeyEvent.VK_STOP, KeyEvent.KEY_TYPED), "swingDummyFocusKey"); } } }
From source file:com.haulmont.cuba.desktop.gui.components.DesktopTextArea.java
@Override protected JTextArea createTextComponentImpl() { final JTextArea impl = new TextAreaFlushableField(); if (isTabTraversal()) { Set<KeyStroke> forwardFocusKey = Collections.singleton(getKeyStroke(KeyEvent.VK_TAB, 0)); impl.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, forwardFocusKey); Set<KeyStroke> backwardFocusKey = Collections .singleton(getKeyStroke(KeyEvent.VK_TAB, KeyEvent.SHIFT_MASK)); impl.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, backwardFocusKey); impl.addKeyListener(new KeyAdapter() { @Override// www . j av a 2s . c om public void keyPressed(KeyEvent e) { if (isEnabled() && isEditable() && e.getKeyCode() == KeyEvent.VK_TAB && e.getModifiers() == KeyEvent.CTRL_MASK) { if (StringUtils.isEmpty(impl.getText())) { impl.setText("\t"); } else { impl.append("\t"); } } } }); } impl.setLineWrap(true); impl.setWrapStyleWord(true); int height = (int) impl.getPreferredSize().getHeight(); impl.setMinimumSize(new Dimension(0, height)); composition = new JScrollPane(impl); composition.setPreferredSize(new Dimension(150, height)); composition.setMinimumSize(new Dimension(0, height)); doc.putProperty("filterNewlines", false); return impl; }
From source file:com.haulmont.cuba.desktop.gui.components.DesktopComponentsHelper.java
/** * Make JTable handle TAB key as all other components - move focus to next/previous components. * <p>Default Swing behaviour for table is to move focus to next/previous cell inside the table.</p> * @param table table instance/* ww w .ja v a 2s . c o m*/ */ public static void correctTableFocusTraversal(JTable table) { table.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, Collections.singleton(AWTKeyStroke.getAWTKeyStroke("TAB"))); table.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, Collections.singleton(AWTKeyStroke.getAWTKeyStroke("shift TAB"))); }
From source file:forge.itemmanager.views.ItemListView.java
/** * ItemTable Constructor.//from w ww. jav a 2s .c om * * @param itemManager0 * @param model0 */ public ItemListView(final ItemManager<T> itemManager0, final ItemManagerModel<T> model0) { super(itemManager0, model0); this.tableModel = new ItemTableModel(model0); this.setAllowMultipleSelections(false); this.getPnlOptions().setVisible(false); //hide options panel by default // use different selection highlight colors for focused vs. unfocused tables this.table.addMouseListener(new FMouseAdapter() { @Override public void onLeftDoubleClick(final MouseEvent e) { if (e.isConsumed()) { return; } //don't activate if inline button double clicked final int clickedIndex = table.rowAtPoint(e.getPoint()); itemManager.activateSelectedItems(); if (clickedIndex >= table.getRowCount()) { FMouseAdapter.forceMouseUp(); //prevent mouse getting stuck if final row removed from double click handling } } @Override public void onRightClick(final MouseEvent e) { itemManager.showContextMenu(e); } }); // prevent tables from intercepting tab focus traversals this.table.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, null); this.table.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, null); }
From source file:edu.ku.brc.specify.tasks.subpane.wb.FormPane.java
/** * Adds Up/Down Focus Traversal Keys to the form. *//*from w w w . ja v a 2s.c o m*/ protected void addArrowTraversalKeys() { Set<AWTKeyStroke> set = getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS); KeyStroke forward = KeyStroke.getKeyStroke("DOWN"); set = new HashSet<AWTKeyStroke>(set); set.add(forward); setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, set); set = getFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS); KeyStroke backward = KeyStroke.getKeyStroke("UP"); set = new HashSet<AWTKeyStroke>(set); set.add(backward); setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, set); }
From source file:net.sf.jabref.EntryEditor.java
/** * NOTE: This method is only used for the source panel, not for the * other tabs. Look at EntryEditorTab for the setup of text components * in the other tabs./*ww w.ja v a 2 s . c om*/ */ private void setupJTextFieldForSourceArea(JTextComponent ta) { setupSwingComponentKeyBindings(ta); // HashSet<AWTKeyStroke> keys = new HashSet<AWTKeyStroke>(ta.getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS)); HashSet<AWTKeyStroke> keys = new HashSet<AWTKeyStroke>(); keys.add(AWTKeyStroke.getAWTKeyStroke("pressed TAB")); ta.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, keys); // keys = new HashSet<AWTKeyStroke>(ta.getFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS)); keys = new HashSet<AWTKeyStroke>(); keys.add(KeyStroke.getKeyStroke("shift pressed TAB")); ta.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, keys); ta.addFocusListener(new FieldListener()); }