javax.swing.plaf.ComponentInputMapUIResource Java Examples

The following examples show how to use javax.swing.plaf.ComponentInputMapUIResource. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DarkTabbedPaneUIBridge.java    From darklaf with MIT License 5 votes vote down vote up
/**
 * Installs the state needed for mnemonics.
 */
protected void initMnemonics() {
    mnemonicToIndexMap = new Hashtable<>();
    mnemonicInputMap = new ComponentInputMapUIResource(tabPane);
    mnemonicInputMap.setParent(SwingUtilities.getUIInputMap(tabPane,
                                                            JComponent.WHEN_IN_FOCUSED_WINDOW));
    SwingUtilities.replaceUIInputMap(tabPane,
                                     JComponent.WHEN_IN_FOCUSED_WINDOW,
                                     mnemonicInputMap);
}
 
Example #2
Source File: WTabbedPaneInputListener.java    From weblaf with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void install ( @NotNull final C component )
{
    super.install ( component );

    // Installing listeners
    component.addPropertyChangeListener ( this );
    component.addMouseListener ( this );
    component.addMouseWheelListener ( this );

    // Installing ActionMap
    final UIActionMap actionMap = new UIActionMap ();
    actionMap.put ( new Actions ( component, Actions.NEXT ) );
    actionMap.put ( new Actions ( component, Actions.PREVIOUS ) );
    actionMap.put ( new Actions ( component, Actions.RIGHT ) );
    actionMap.put ( new Actions ( component, Actions.LEFT ) );
    actionMap.put ( new Actions ( component, Actions.UP ) );
    actionMap.put ( new Actions ( component, Actions.DOWN ) );
    actionMap.put ( new Actions ( component, Actions.PAGE_UP ) );
    actionMap.put ( new Actions ( component, Actions.PAGE_DOWN ) );
    actionMap.put ( new Actions ( component, Actions.REQUEST_FOCUS ) );
    actionMap.put ( new Actions ( component, Actions.REQUEST_FOCUS_FOR_VISIBLE ) );
    actionMap.put ( new Actions ( component, Actions.SET_SELECTED ) );
    actionMap.put ( new Actions ( component, Actions.SCROLL_FORWARD ) );
    actionMap.put ( new Actions ( component, Actions.SCROLL_BACKWARD ) );
    SwingUtilities.replaceUIActionMap ( component, actionMap );

    // Installing InputMap
    final InputMap focusedMap = LafLookup.getInputMap ( component, JComponent.WHEN_FOCUSED );
    SwingUtilities.replaceUIInputMap ( component, JComponent.WHEN_FOCUSED, focusedMap );
    final InputMap ancestorMap = LafLookup.getInputMap ( component, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT );
    SwingUtilities.replaceUIInputMap ( component, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, ancestorMap );

    // Installing mnemonic InputMap
    mnemonicInputMap = new ComponentInputMapUIResource ( component );
    mnemonicInputMap.setParent ( SwingUtilities.getUIInputMap ( component, JComponent.WHEN_IN_FOCUSED_WINDOW ) );
    SwingUtilities.replaceUIInputMap ( component, JComponent.WHEN_IN_FOCUSED_WINDOW, mnemonicInputMap );
}
 
Example #3
Source File: BasicPopupPanelUI.java    From radiance with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * Installs the maps on the root pane of the originating component of
 * the first popup panel of the specified sequence to trace the ESC key
 * and dismiss the shown popup panels.
 *
 * @param shownPath Popup panel sequence.
 */
private void traceRootPane(List<PopupPanelManager.PopupInfo> shownPath) {
    JComponent originator = shownPath.get(0).getPopupOriginator();
    this.tracedRootPane = SwingUtilities.getRootPane(originator);

    if (this.tracedRootPane != null) {
        newInputMap = new ComponentInputMapUIResource(tracedRootPane);
        newInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
                "hidePopupPanel");

        newActionMap = new ActionMapUIResource();
        newActionMap.put("hidePopupPanel", new AbstractAction() {
            @Override
            public void actionPerformed(ActionEvent e) {
                // Hide the last sequence popup for every ESC keystroke.
                // There is special case - if the keytips are shown
                // for the *second* panel of the app menu popup panel,
                // do not dismiss the popup
                List<PopupPanelManager.PopupInfo> popups = PopupPanelManager
                        .defaultManager().getShownPath();
                if (popups.size() > 0) {
                    PopupPanelManager.PopupInfo lastPopup = popups
                            .get(popups.size() - 1);
                    if (lastPopup.getPopupPanel() instanceof JRibbonApplicationMenuPopupPanel) {
                        JRibbonApplicationMenuPopupPanel appMenuPopupPanel =
                                (JRibbonApplicationMenuPopupPanel) lastPopup
                                        .getPopupPanel();
                        KeyTipManager.KeyTipChain currentlyShownKeyTipChain = KeyTipManager
                                .defaultManager().getCurrentlyShownKeyTipChain();
                        if ((currentlyShownKeyTipChain != null)
                                && (currentlyShownKeyTipChain.chainParentComponent == appMenuPopupPanel
                                .getPanelLevel2()))
                            return;
                    }
                }
                PopupPanelManager.defaultManager().hideLastPopup();
            }
        });

        addUIInputMap(tracedRootPane, newInputMap);
        addUIActionMap(tracedRootPane, newActionMap);
    }
}