List of usage examples for javax.swing JComponent WHEN_IN_FOCUSED_WINDOW
int WHEN_IN_FOCUSED_WINDOW
To view the source code for javax.swing JComponent WHEN_IN_FOCUSED_WINDOW.
Click Source Link
registerKeyboardAction
that means that the command should be invoked when the receiving component is in the window that has the focus or is itself the focused component. From source file:org.ut.biolab.medsavant.client.util.ClientMiscUtils.java
/** * Register the escape key so that it can be used to cancel the associated JDialog. */// ww w.j av a 2 s . c o m public static void registerCancelButton(final JButton cancelButton) { KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); JDialog dialog = (JDialog) SwingUtilities.getWindowAncestor(cancelButton); dialog.getRootPane().registerKeyboardAction(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { cancelButton.doClick(); } }, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); }
From source file:org.yccheok.jstock.gui.JStock.java
private void initKeyBindings() { KeyStroke watchlistNavigationKeyStroke = KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_W, java.awt.event.InputEvent.CTRL_MASK); KeyStroke portfolioNavigationKeyStroke = KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_P, java.awt.event.InputEvent.CTRL_MASK); getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(watchlistNavigationKeyStroke, "watchlistNavigation"); getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(portfolioNavigationKeyStroke, "portfolioNavigation"); getRootPane().getActionMap().put("watchlistNavigation", new AbstractAction() { @Override//from w ww . ja va 2s.com public void actionPerformed(ActionEvent e) { watchlistNavigation(); } }); getRootPane().getActionMap().put("portfolioNavigation", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { portfolioNavigation(); } }); }
From source file:pcgen.gui2.tools.Utility.java
/** * Add a keyboard shortcut to allow ESC to close the dialog. * * @param dialog The dialog to be updated. *///from w ww . j a v a 2s . c o m public static void installEscapeCloseOperation(final JDialog dialog) { JRootPane root = dialog.getRootPane(); root.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(escapeStroke, dispatchWindowClosingActionMapKey); Action dispatchClosing = new AbstractAction() { @Override public void actionPerformed(ActionEvent event) { dialog.dispatchEvent(new WindowEvent(dialog, WindowEvent.WINDOW_CLOSING)); } }; root.getActionMap().put(dispatchWindowClosingActionMapKey, dispatchClosing); }
From source file:processing.app.Base.java
/** * Registers key events for a Ctrl-W and ESC with an ActionListener * that will take care of disposing the window. */// w w w .j a v a2 s .c o m static public void registerWindowCloseKeys(JRootPane root, ActionListener disposer) { KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); root.registerKeyboardAction(disposer, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); int modifiers = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); stroke = KeyStroke.getKeyStroke('W', modifiers); root.registerKeyboardAction(disposer, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); }
From source file:ru.apertum.qsystem.client.forms.FReception.java
/** * Creates new form FReception/*www . j a v a2 s. c o m*/ * * @param netProperty */ public FReception(IClientNetProperty netProperty) { this.netProperty = netProperty; initComponents(); setTitle(getTitle() + " " + Uses.getLocaleMessage("project.name" + FAbout.getCMRC_SUFF())); //NOI18N try { setIconImage(ImageIO .read(FAdmin.class.getResource("/ru/apertum/qsystem/client/forms/resources/monitor.png"))); //NOI18N } catch (IOException ex) { System.err.println(ex); } // . Escape // ? esc getRootPane().registerKeyboardAction((ActionEvent e) -> { setVisible(false); }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW); // trayIcon, .. setSituation() ? tray final JFrame fr = this; tray = QTray.getInstance(fr, "/ru/apertum/qsystem/client/forms/resources/monitor.png", getTitle()); //NOI18N tray.addItem(getLocaleMessage("messages.tray.showClient"), (ActionEvent e) -> { setVisible(true); setState(JFrame.NORMAL); }); tray.addItem("-", (ActionEvent e) -> { }); tray.addItem(getLocaleMessage("messages.tray.close"), (ActionEvent e) -> { dispose(); System.exit(0); }); int ii = 1; final ButtonGroup bg = new ButtonGroup(); final String currLng = Locales.getInstance().getLangCurrName(); for (String lng : Locales.getInstance().getAvailableLocales()) { final JRadioButtonMenuItem item = new JRadioButtonMenuItem( org.jdesktop.application.Application.getInstance(ru.apertum.qsystem.QSystem.class).getContext() .getActionMap(FReception.class, fr).get("setCurrentLang")); //NOI18N bg.add(item); item.setSelected(lng.equals(currLng)); item.setText(lng); // NOI18N item.setName("QRadioButtonMenuItem" + (ii++)); // NOI18N menuLangs.add(item); } treeServices.addTreeSelectionListener((TreeSelectionEvent e) -> { serviceListChange(); }); // ?? ??. listUsers.addListSelectionListener((ListSelectionEvent e) -> { userListChange(); }); }
From source file:se.trixon.mapollage.ui.MainFrame.java
private void initActions() { mActionManager = ActionManager.getInstance().init(getRootPane().getActionMap(), getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)); InputMap inputMap = mPopupMenu.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); ActionMap actionMap = mPopupMenu.getActionMap(); Action action = new AbstractAction("HideMenu") { @Override/*from w w w . ja v a 2s . com*/ public void actionPerformed(ActionEvent e) { mPopupMenu.setVisible(false); } }; String key = "HideMenu"; actionMap.put(key, action); KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); inputMap.put(keyStroke, key); //about PomInfo pomInfo = new PomInfo(Mapollage.class, "se.trixon", "mapollage"); AboutModel aboutModel = new AboutModel(SystemHelper.getBundle(Mapollage.class, "about"), SystemHelper.getResourceAsImageIcon(MainFrame.class, "icon-1024px.png")); aboutModel.setAppVersion(pomInfo.getVersion()); AboutPanel aboutPanel = new AboutPanel(aboutModel); action = AboutPanel.getAction(MainFrame.this, aboutPanel); getRootPane().getActionMap().put(ActionManager.ABOUT, action); //File quitMenuItem.setAction(mActionManager.getAction(ActionManager.QUIT)); //Profile addMenuItem.setAction(mActionManager.getAction(ActionManager.ADD)); cloneMenuItem.setAction(mActionManager.getAction(ActionManager.CLONE)); renameMenuItem.setAction(mActionManager.getAction(ActionManager.RENAME)); removeMenuItem.setAction(mActionManager.getAction(ActionManager.REMOVE)); removeAllMenuItem.setAction(mActionManager.getAction(ActionManager.REMOVE_ALL)); //Tools optionsMenuItem.setAction(mActionManager.getAction(ActionManager.OPTIONS)); //Help helpMenuItem.setAction(mActionManager.getAction(ActionManager.HELP)); aboutDateFormatMenuItem.setAction(mActionManager.getAction(ActionManager.ABOUT_DATE_FORMAT)); aboutMenuItem.setAction(mActionManager.getAction(ActionManager.ABOUT)); //Toolbar startButton.setAction(mActionManager.getAction(ActionManager.START)); cancelButton.setAction(mActionManager.getAction(ActionManager.CANCEL)); menuButton.setAction(mActionManager.getAction(ActionManager.MENU)); SwingHelper.clearText(toolBar); }
From source file:se.trixon.pacoma.ui.MainFrame.java
private void initActions() { mActionManager = ActionManager.getInstance().init(getRootPane().getActionMap(), getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)); InputMap inputMap = mPopupMenu.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); ActionMap actionMap = mPopupMenu.getActionMap(); Action action = new AbstractAction("HideMenu") { @Override/* w ww .j a v a 2s . c o m*/ public void actionPerformed(ActionEvent e) { mPopupMenu.setVisible(false); } }; String key = "HideMenu"; actionMap.put(key, action); KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); inputMap.put(keyStroke, key); //about PomInfo pomInfo = new PomInfo(Pacoma.class, "se.trixon", "pacoma"); AboutModel aboutModel = new AboutModel(SystemHelper.getBundle(Pacoma.class, "about"), SystemHelper.getResourceAsImageIcon(MainFrame.class, "pacoma-icon.png")); aboutModel.setAppVersion(pomInfo.getVersion()); AboutPanel aboutPanel = new AboutPanel(aboutModel); action = AboutPanel.getAction(MainFrame.this, aboutPanel); getRootPane().getActionMap().put(ActionManager.ABOUT, action); //File newButton.setAction(mActionManager.getAction(ActionManager.NEW)); newMenuItem.setAction(mActionManager.getAction(ActionManager.NEW)); openButton.setAction(mActionManager.getAction(ActionManager.OPEN)); openMenuItem.setAction(mActionManager.getAction(ActionManager.OPEN)); closeButton.setAction(mActionManager.getAction(ActionManager.CLOSE)); closeMenuItem.setAction(mActionManager.getAction(ActionManager.CLOSE)); saveButton.setAction(mActionManager.getAction(ActionManager.SAVE)); saveMenuItem.setAction(mActionManager.getAction(ActionManager.SAVE)); saveAsButton.setAction(mActionManager.getAction(ActionManager.SAVE_AS)); saveAsMenuItem.setAction(mActionManager.getAction(ActionManager.SAVE_AS)); propertiesMenuItem.setAction(mActionManager.getAction(ActionManager.PROPERTIES)); propertiesButton.setAction(mActionManager.getAction(ActionManager.PROPERTIES)); quitMenuItem.setAction(mActionManager.getAction(ActionManager.QUIT)); //Edit undoMenuItem.setAction(mActionManager.getAction(ActionManager.UNDO)); undoButton.setAction(mActionManager.getAction(ActionManager.UNDO)); undoButton.setText(""); redoMenuItem.setAction(mActionManager.getAction(ActionManager.REDO)); redoButton.setAction(mActionManager.getAction(ActionManager.REDO)); redoButton.setText(""); //Tools optionsMenuItem.setAction(mActionManager.getAction(ActionManager.OPTIONS)); //Help helpMenuItem.setAction(mActionManager.getAction(ActionManager.HELP)); aboutMenuItem.setAction(mActionManager.getAction(ActionManager.ABOUT)); //Toolbar addButton.setAction(mActionManager.getAction(ActionManager.ADD)); clearButton.setAction(mActionManager.getAction(ActionManager.CLEAR)); regenerateButton.setAction(mActionManager.getAction(ActionManager.REGENERATE)); // startButton.setAction(mActionManager.getAction(ActionManager.START)); // cancelButton.setAction(mActionManager.getAction(ActionManager.CANCEL)); menuButton.setAction(mActionManager.getAction(ActionManager.MENU)); renderButton.setAction(mActionManager.getAction(ActionManager.START)); SwingHelper.clearTextButtons(menuButton); }
From source file:simplealbum.mvc.autocomplete.DController.java
private void configureKeyBoard() { reassignKeyStrokes(jTextPane, JComponent.WHEN_FOCUSED, "pressed ENTER", "shift pressed ENTER"); assignKeyStrokes(view.getRootPane(), JComponent.WHEN_IN_FOCUSED_WINDOW, "pressed ENTER", new MyAction("pressed ENTER")); assignKeyStrokes(view.getRootPane(), JComponent.WHEN_IN_FOCUSED_WINDOW, "pressed ESCAPE", new MyAction("DO_ESCAPE")); reassignKeyStrokes(jTextPane, JComponent.WHEN_FOCUSED, "pressed TAB", "shift pressed TAB"); assignKeyStrokes(view.getRootPane(), JComponent.WHEN_IN_FOCUSED_WINDOW, "pressed TAB", new MyAction("DO_TAB")); reassignKeyStrokes(jTextPane, JComponent.WHEN_FOCUSED, "pressed UP", "alt UP"); reassignKeyStrokes(jScrollPane, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, "pressed UP", "alt UP"); assignKeyStrokes(view.getRootPane(), JComponent.WHEN_IN_FOCUSED_WINDOW, "pressed UP", new MyAction("DO_UP")); reassignKeyStrokes(jTextPane, JComponent.WHEN_FOCUSED, "pressed DOWN", "alt DOWN"); reassignKeyStrokes(jScrollPane, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, "pressed DOWN", "alt DOWN"); assignKeyStrokes(view.getRootPane(), JComponent.WHEN_IN_FOCUSED_WINDOW, "pressed DOWN", new MyAction("DO_DOWN")); reassignKeyStrokes(jTextPane, JComponent.WHEN_FOCUSED, "pressed PAGE_UP", "alt PAGE_UP"); reassignKeyStrokes(jScrollPane, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, "pressed PAGE_UP", "alt PAGE_UP"); assignKeyStrokes(view.getRootPane(), JComponent.WHEN_IN_FOCUSED_WINDOW, "pressed PAGE_UP", new MyAction("DO_PAGE_UP")); reassignKeyStrokes(jTextPane, JComponent.WHEN_FOCUSED, "pressed PAGE_DOWN", "alt PAGE_DOWN"); reassignKeyStrokes(jScrollPane, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, "pressed PAGE_DOWN", "alt PAGE_DOWN"); assignKeyStrokes(view.getRootPane(), JComponent.WHEN_IN_FOCUSED_WINDOW, "pressed PAGE_DOWN", new MyAction("DO_PAGE_DOWN")); assignKeyStrokes(view.getRootPane(), JComponent.WHEN_IN_FOCUSED_WINDOW, "pressed F5", new MyAction("pressed F5")); }
From source file:studio.ui.Studio.java
public Studio(AppConfig config, String... args) { super(AppInformation.getInformation().getTitle()); setIconImage(IconsItem.IMAGE_APP);/*w ww . ja v a 2s . c o m*/ enableEvents(AWTEvent.WINDOW_EVENT_MASK); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); setSize((int) (0.9 * screenSize.width), (int) (0.9 * screenSize.height)); setLocation(((int) Math.max(0, (screenSize.width - getWidth()) / 2.0)), (int) (Math.max(0, (screenSize.height - getHeight()) / 2.0))); this.studioConfig = config; if (studioConfig.isMaximized()) { setExtendedState(JFrame.MAXIMIZED_BOTH); //Maximizing the frame } addWindowStateListener(this); registerForMacOSXEvents(); splitViewer = new JSplitPane(); splitTopViewer = new JSplitPane(); tabConsoles = new ConsolesTabbedPane(); tabConsoles.addFireDataListener(this); tabEditors = new EditorsTabbedPane(tabConsoles); tabEditors.addFireDataListener(this); if (tabConsoles instanceof DataListener) { tabEditors.addFireDataListener((DataListener) tabConsoles); } tools = new ToolsPanel(); splitViewer.setOrientation(JSplitPane.VERTICAL_SPLIT); splitViewer.setDividerSize(0); splitViewer.setTopComponent(splitTopViewer); splitViewer.setBottomComponent(tabConsoles); splitViewer.setOneTouchExpandable(true); splitTopViewer.setOrientation(JSplitPane.HORIZONTAL_SPLIT); splitTopViewer.setDividerSize(9); splitTopViewer.setTopComponent(tools); splitTopViewer.setBottomComponent(tabEditors); splitTopViewer.setOneTouchExpandable(true); createConnectionsTree(); createProjectsTree(); rebuildMenus(null); getContentPane().add(splitViewer, BorderLayout.CENTER); splitViewer.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent event) { if (event.getComponent() instanceof JSplitPane) { if (((JSplitPane) event.getComponent()).getDividerSize() == 0) { ((JSplitPane) event.getComponent()).setDividerLocation(1d); } } } }); this.setVisible(true); splitTopViewer.setDividerLocation(.2d); splitViewer.setDividerLocation(1d); NewFileAction newAction = null; OpenFileAction openAction = null; ToolBarActions toolbar = appToolbar != null ? appToolbar.getToolBar("File") : null; if (toolbar != null) { for (int count = 0; count < toolbar.getComponentCount(); count++) { if (toolbar.getComponent(count) instanceof JButton) { if (((JButton) toolbar.getComponent(count)).getAction().getClass() == OpenFileAction.class) { openAction = (OpenFileAction) ((JButton) toolbar.getComponent(count)).getAction(); } else { if (((JButton) toolbar.getComponent(count)).getAction().getClass() == NewFileAction.class) { newAction = (NewFileAction) ((JButton) toolbar.getComponent(count)).getAction(); } } if (openAction != null && newAction != null) { break; } } } } EditorFile last = null; if (config.getLastFiles() != null && !config.getLastFiles().isEmpty()) { for (EditorFile file : config.getLastFiles()) { if (file.isActive()) { last = file; } try { openAction.initDocument(file); } catch (FileException ex) { JOptionPane.showMessageDialog(this, ex.getMessage(), "File", JOptionPane.WARNING_MESSAGE); } } } else { if (args == null || args.length == 0) { newAction.actionPerformed(null); } } if (args != null && args.length > 0) { for (String arg : args) { File file = new File(arg); if (file.exists() && file.canRead()) { try { openAction.initDocument(new EditorFile(file)); } catch (FileException ex) { JOptionPane.showMessageDialog(this, ex.getMessage(), "File", JOptionPane.WARNING_MESSAGE); } } } } if (tabEditors.getTabCount() > 0) { if (last == null) { tabEditors.setSelectedIndex(0); } else { for (int count = 0; count < tabEditors.getTabCount(); count++) { if (tabEditors.getEditor(count).getFile().equals(last)) { tabEditors.setSelectedIndex(count); } } } tabEditors.getEditor().requestFocusInWindow(); } ActionBase action = new ActionBase(null, (char) 0, null, null, null, null) { private static final long serialVersionUID = -1752094455650906542L; @Override public void actionPerformed(ActionEvent event) { treeConnections.requestFocus(); } }; splitViewer.registerKeyboardAction(action, KeyStroke.getKeyStroke("F5"), JComponent.WHEN_IN_FOCUSED_WINDOW); splitViewer.registerKeyboardAction(action, KeyStroke.getKeyStroke("control F5"), JComponent.WHEN_IN_FOCUSED_WINDOW); action = new ActionBase(null, (char) 0, null, null, null, null) { private static final long serialVersionUID = -1752094455650906542L; @Override public void actionPerformed(ActionEvent event) { if (tabEditors.getTabCount() > 0) { tabEditors.requestFocus(); tabEditors.getEditor().requestFocus(); } } }; splitViewer.registerKeyboardAction(action, KeyStroke.getKeyStroke("F3"), JComponent.WHEN_IN_FOCUSED_WINDOW); splitViewer.registerKeyboardAction(action, KeyStroke.getKeyStroke("control F3"), JComponent.WHEN_IN_FOCUSED_WINDOW); action = new ActionBase(null, (char) 0, null, null, null, null) { private static final long serialVersionUID = -7472441241172668338L; @Override public void actionPerformed(ActionEvent event) { treeProjects.requestFocus(); } }; splitViewer.registerKeyboardAction(action, KeyStroke.getKeyStroke("F6"), JComponent.WHEN_IN_FOCUSED_WINDOW); splitViewer.registerKeyboardAction(action, KeyStroke.getKeyStroke("control F6"), JComponent.WHEN_IN_FOCUSED_WINDOW); action = new ActionBase(null, (char) 0, null, null, null, null) { private static final long serialVersionUID = -1752094455650906542L; @Override public void actionPerformed(ActionEvent event) { if (tabConsoles.getTabCount() > 0) { tabConsoles.requestFocus(); if (tabConsoles.getSelectedIndex() != -1) { tabConsoles.getComponentAt(tabConsoles.getSelectedIndex()).requestFocus(); } } } }; splitViewer.registerKeyboardAction(action, KeyStroke.getKeyStroke("F4"), JComponent.WHEN_IN_FOCUSED_WINDOW); splitViewer.registerKeyboardAction(action, KeyStroke.getKeyStroke("control F4"), JComponent.WHEN_IN_FOCUSED_WINDOW); action = new WindowsListAction(tabEditors); splitViewer.registerKeyboardAction(action, action.getAccelerator(), JComponent.WHEN_IN_FOCUSED_WINDOW); }
From source file:tvbrowser.ui.mainframe.MainFrame.java
/** * Adds the keyboard actions for going to the program table with the keyboard. * *//*from w w w . ja va 2s .c o m*/ public void addKeyboardAction() { mProgramTableScrollPane.deSelectItem(); // register the global hot keys, so they also work when the main menu is not visible for (final TVBrowserAction action : TVBrowserActions.getActions()) { KeyStroke keyStroke = action.getAccelerator(); if (keyStroke != null) { rootPane.registerKeyboardAction(new ActionListener() { public void actionPerformed(ActionEvent e) { if (action.isEnabled()) { action.actionPerformed(null); } } }, keyStroke, JComponent.WHEN_IN_FOCUSED_WINDOW); } } KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_UP, InputEvent.CTRL_MASK); rootPane.registerKeyboardAction(new KeyboardAction(mProgramTableScrollPane, KeyboardAction.KEY_UP), stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); stroke = KeyStroke.getKeyStroke(KeyEvent.VK_KP_UP, InputEvent.CTRL_MASK); rootPane.registerKeyboardAction(new KeyboardAction(mProgramTableScrollPane, KeyboardAction.KEY_UP), stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); stroke = KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, InputEvent.CTRL_MASK); rootPane.registerKeyboardAction(new KeyboardAction(mProgramTableScrollPane, KeyboardAction.KEY_RIGHT), stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); stroke = KeyStroke.getKeyStroke(KeyEvent.VK_KP_RIGHT, InputEvent.CTRL_MASK); rootPane.registerKeyboardAction(new KeyboardAction(mProgramTableScrollPane, KeyboardAction.KEY_RIGHT), stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); stroke = KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, InputEvent.CTRL_MASK); rootPane.registerKeyboardAction(new KeyboardAction(mProgramTableScrollPane, KeyboardAction.KEY_DOWN), stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); stroke = KeyStroke.getKeyStroke(KeyEvent.VK_KP_DOWN, InputEvent.CTRL_MASK); rootPane.registerKeyboardAction(new KeyboardAction(mProgramTableScrollPane, KeyboardAction.KEY_DOWN), stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); stroke = KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, InputEvent.CTRL_MASK); rootPane.registerKeyboardAction(new KeyboardAction(mProgramTableScrollPane, KeyboardAction.KEY_LEFT), stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); stroke = KeyStroke.getKeyStroke(KeyEvent.VK_KP_LEFT, InputEvent.CTRL_MASK); rootPane.registerKeyboardAction(new KeyboardAction(mProgramTableScrollPane, KeyboardAction.KEY_LEFT), stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); stroke = KeyStroke.getKeyStroke(KeyEvent.VK_CONTEXT_MENU, 0, true); rootPane.registerKeyboardAction(new KeyboardAction(mProgramTableScrollPane, KeyboardAction.KEY_CONTEXTMENU), stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); stroke = KeyStroke.getKeyStroke(KeyEvent.VK_R, 0, true); rootPane.registerKeyboardAction(new KeyboardAction(mProgramTableScrollPane, KeyboardAction.KEY_CONTEXTMENU), stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); stroke = KeyStroke.getKeyStroke(KeyEvent.VK_D, InputEvent.CTRL_MASK); rootPane.registerKeyboardAction(new KeyboardAction(mProgramTableScrollPane, KeyboardAction.KEY_DESELECT), stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); stroke = KeyStroke.getKeyStroke(KeyEvent.VK_L, 0, true); rootPane.registerKeyboardAction(new KeyboardAction(mProgramTableScrollPane, KeyboardAction.KEY_SINGLECLICK), stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); stroke = KeyStroke.getKeyStroke(KeyEvent.VK_D, 0, true); rootPane.registerKeyboardAction(new KeyboardAction(mProgramTableScrollPane, KeyboardAction.KEY_DOUBLECLICK), stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); stroke = KeyStroke.getKeyStroke(KeyEvent.VK_M, 0, true); rootPane.registerKeyboardAction(new KeyboardAction(mProgramTableScrollPane, KeyboardAction.KEY_MIDDLECLICK), stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); stroke = KeyStroke.getKeyStroke(KeyEvent.VK_O, 0, true); rootPane.registerKeyboardAction( new KeyboardAction(mProgramTableScrollPane, KeyboardAction.KEY_MIDDLE_DOUBLE_CLICK), stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); stroke = KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.CTRL_MASK); rootPane.registerKeyboardAction(TVBrowserActions.goToNextDay, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); stroke = KeyStroke.getKeyStroke(KeyEvent.VK_P, InputEvent.CTRL_MASK); rootPane.registerKeyboardAction(TVBrowserActions.goToPreviousDay, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); // return from full screen using ESCAPE stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); rootPane.registerKeyboardAction(new ActionListener() { public void actionPerformed(ActionEvent e) { if (isFullScreenMode()) { TVBrowserActions.fullScreen.actionPerformed(null); } else { mProgramTableScrollPane.getProgramTable().stopAutoScroll(); mAutoDownloadTimer = -1; mLastTimerMinutesAfterMidnight = IOUtilities.getMinutesAfterMidnight(); TVBrowser.stopAutomaticDownload(); if (TVBrowserActions.update.isUpdating()) { TVBrowserActions.update.actionPerformed(null); } } } }, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); stroke = KeyStroke.getKeyStroke(KeyEvent.VK_HOME, 0); rootPane.registerKeyboardAction(new ActionListener() { public void actionPerformed(ActionEvent e) { goToLeftSide(); } }, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); stroke = KeyStroke.getKeyStroke(KeyEvent.VK_END, 0); rootPane.registerKeyboardAction(new ActionListener() { public void actionPerformed(ActionEvent e) { goToRightSide(); } }, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); stroke = KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, InputEvent.SHIFT_MASK); rootPane.registerKeyboardAction(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { mProgramTableScrollPane.scrollPageRight(); } }, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); stroke = KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, InputEvent.SHIFT_MASK); rootPane.registerKeyboardAction(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { mProgramTableScrollPane.scrollPageLeft(); } }, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); this.setRootPane(rootPane); }