Java Code Examples for javax.swing.SwingUtilities#replaceUIInputMap()

The following examples show how to use javax.swing.SwingUtilities#replaceUIInputMap() . These examples are extracted from open source projects. 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
@Override
protected void installKeyboardActions() {
    super.installKeyboardActions();

    JTextComponent comp = getComponent();

    UIDefaults uidefaults = XToolkit.getUIDefaults();

    String prefix = getPropertyPrefix();

    InputMap map = (InputMap)uidefaults.get(prefix + ".focusInputMap");

    if (map != null) {
        SwingUtilities.replaceUIInputMap(comp, JComponent.WHEN_FOCUSED,
                                         map);
    }
}
 
Example 2
@Override
protected void installKeyboardActions() {
    super.installKeyboardActions();

    JTextComponent comp = getComponent();

    UIDefaults uidefaults = XToolkit.getUIDefaults();

    String prefix = getPropertyPrefix();

    InputMap map = (InputMap)uidefaults.get(prefix + ".focusInputMap");

    if (map != null) {
        SwingUtilities.replaceUIInputMap(comp, JComponent.WHEN_FOCUSED,
                                         map);
    }
}
 
Example 3
@Override
protected void installKeyboardActions() {
    super.installKeyboardActions();

    JTextComponent comp = getComponent();

    UIDefaults uidefaults = XToolkit.getUIDefaults();

    String prefix = getPropertyPrefix();

    InputMap map = (InputMap)uidefaults.get(prefix + ".focusInputMap");

    if (map != null) {
        SwingUtilities.replaceUIInputMap(comp, JComponent.WHEN_FOCUSED,
                                         map);
    }
}
 
Example 4
@Override
protected void installKeyboardActions() {
    super.installKeyboardActions();

    JTextComponent comp = getComponent();

    UIDefaults uidefaults = XToolkit.getUIDefaults();

    String prefix = getPropertyPrefix();

    InputMap map = (InputMap)uidefaults.get(prefix + ".focusInputMap");

    if (map != null) {
        SwingUtilities.replaceUIInputMap(comp, JComponent.WHEN_FOCUSED,
                                         map);
    }
}
 
Example 5
@Override
protected void installKeyboardActions() {
    super.installKeyboardActions();

    JTextComponent comp = getComponent();

    UIDefaults uidefaults = XToolkit.getUIDefaults();

    String prefix = getPropertyPrefix();

    InputMap map = (InputMap)uidefaults.get(prefix + ".focusInputMap");

    if (map != null) {
        SwingUtilities.replaceUIInputMap(comp, JComponent.WHEN_FOCUSED,
                                         map);
    }
}
 
Example 6
Source Project: diirt   File: CompareResultImages.java    License: MIT License 6 votes vote down vote up
/**
 * Creates new form CompareResultImages
 */
public CompareResultImages() {
    initComponents();
    toReviewList.setModel(new DefaultListModel());
    fillList();
    setSize(800, 600);
    setExtendedState(getExtendedState() | MAXIMIZED_BOTH);
    actualImage.setStretch(false);
    referenceImage.setStretch(false);
    acceptAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("control D"));

    InputMap keyMap = new ComponentInputMap(acceptButton);
    keyMap.put(KeyStroke.getKeyStroke("control D"), "accept");

    ActionMap actionMap = new ActionMapUIResource();
    actionMap.put("accept", acceptAction);

    SwingUtilities.replaceUIActionMap(acceptButton, actionMap);
    SwingUtilities.replaceUIInputMap(acceptButton, JComponent.WHEN_IN_FOCUSED_WINDOW, keyMap);
}
 
Example 7
@Override
protected void installKeyboardActions() {
    super.installKeyboardActions();

    JTextComponent comp = getComponent();

    UIDefaults uidefaults = XToolkit.getUIDefaults();

    String prefix = getPropertyPrefix();

    InputMap map = (InputMap)uidefaults.get(prefix + ".focusInputMap");

    if (map != null) {
        SwingUtilities.replaceUIInputMap(comp, JComponent.WHEN_FOCUSED,
                                         map);
    }
}
 
Example 8
@Override
protected void installKeyboardActions() {
    super.installKeyboardActions();

    JTextComponent comp = getComponent();

    UIDefaults uidefaults = XToolkit.getUIDefaults();

    String prefix = getPropertyPrefix();

    InputMap map = (InputMap)uidefaults.get(prefix + ".focusInputMap");

    if (map != null) {
        SwingUtilities.replaceUIInputMap(comp, JComponent.WHEN_FOCUSED,
                                         map);
    }
}
 
Example 9
@Override
protected void installKeyboardActions() {
    super.installKeyboardActions();

    JTextComponent comp = getComponent();

    UIDefaults uidefaults = XToolkit.getUIDefaults();

    String prefix = getPropertyPrefix();

    InputMap map = (InputMap)uidefaults.get(prefix + ".focusInputMap");

    if (map != null) {
        SwingUtilities.replaceUIInputMap(comp, JComponent.WHEN_FOCUSED,
                                         map);
    }
}
 
Example 10
@Override
protected void installKeyboardActions() {
    super.installKeyboardActions();

    JTextComponent comp = getComponent();

    UIDefaults uidefaults = XToolkit.getUIDefaults();

    String prefix = getPropertyPrefix();

    InputMap map = (InputMap)uidefaults.get(prefix + ".focusInputMap");

    if (map != null) {
        SwingUtilities.replaceUIInputMap(comp, JComponent.WHEN_FOCUSED,
                                         map);
    }
}
 
Example 11
@Override
protected void installKeyboardActions() {
    super.installKeyboardActions();

    JTextComponent comp = getComponent();

    UIDefaults uidefaults = XToolkit.getUIDefaults();

    String prefix = getPropertyPrefix();

    InputMap map = (InputMap)uidefaults.get(prefix + ".focusInputMap");

    if (map != null) {
        SwingUtilities.replaceUIInputMap(comp, JComponent.WHEN_FOCUSED,
                                         map);
    }
}
 
Example 12
Source Project: blog-codes   File: mxKeyboardHandler.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Invoked as part from the boilerplate install block.
 */
protected void installKeyboardActions(mxGraphComponent graphComponent)
{
	InputMap inputMap = getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
	SwingUtilities.replaceUIInputMap(graphComponent,
			JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, inputMap);

	inputMap = getInputMap(JComponent.WHEN_FOCUSED);
	SwingUtilities.replaceUIInputMap(graphComponent,
			JComponent.WHEN_FOCUSED, inputMap);
	SwingUtilities.replaceUIActionMap(graphComponent, createActionMap());
}
 
Example 13
Source Project: FlatLaf   File: FlatScrollBarUI.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected PropertyChangeListener createPropertyChangeListener() {
	return new BasicScrollBarUI.PropertyChangeHandler() {
		@Override
		public void propertyChange( PropertyChangeEvent e ) {
			super.propertyChange( e );

			switch( e.getPropertyName() ) {
				case FlatClientProperties.SCROLL_BAR_SHOW_BUTTONS:
					scrollbar.revalidate();
					scrollbar.repaint();
					break;

				case "componentOrientation":
					// this is missing in BasicScrollBarUI.Handler.propertyChange()
					InputMap inputMap = (InputMap) UIManager.get( "ScrollBar.ancestorInputMap" );
					if( !scrollbar.getComponentOrientation().isLeftToRight() ) {
						InputMap rtlInputMap = (InputMap) UIManager.get( "ScrollBar.ancestorInputMap.RightToLeft" );
						if( rtlInputMap != null ) {
							rtlInputMap.setParent( inputMap );
							inputMap = rtlInputMap;
						}
					}
					SwingUtilities.replaceUIInputMap( scrollbar, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, inputMap );
					break;
			}
		}
	};
}
 
Example 14
Source Project: iBioSim   File: CloseTabPaneUI.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Installs the state needed for mnemonics.
 */
private void initMnemonics() {
	mnemonicToIndexMap = new Hashtable<Integer, Integer>();
	mnemonicInputMap = new InputMapUIResource();
	mnemonicInputMap.setParent(SwingUtilities.getUIInputMap(tabPane, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT));
	SwingUtilities.replaceUIInputMap(tabPane, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, mnemonicInputMap);
}
 
Example 15
private void uninstallMaps() {
    InputMap currMap = SwingUtilities.getUIInputMap(this.jcomp,
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);

    InputMap newMap = new InputMap();
    if (currMap != null) {
        KeyStroke[] kss = currMap.allKeys();
        for (int i = 0; i < kss.length; i++) {
            KeyStroke stroke = kss[i];
            Object val = currMap.get(stroke);
            if (stroke
                    .equals(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, InputEvent.CTRL_DOWN_MASK))) {
                if ("tabSwitcherForward".equals(val))
                    continue;
            }
            if (stroke.equals(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, InputEvent.CTRL_DOWN_MASK))) {
                if ("tabSwitcherBackward".equals(val))
                    continue;
            }
            if (stroke.equals(KeyStroke.getKeyStroke(KeyEvent.VK_CONTROL, 0, true))) {
                if ("tabSwitcherClose".equals(val))
                    continue;
            }
            if (stroke.equals(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0))) {
                if ("tabSwitcherHide".equals(val))
                    continue;
            }
            newMap.put(stroke, val);
        }
    }

    this.jcomp.getActionMap().remove("tabSwitcherForward");
    this.jcomp.getActionMap().remove("tabSwitcherBackward");
    this.jcomp.getActionMap().remove("tabSwitcherClose");
    this.jcomp.getActionMap().remove("tabSwitcherHide");

    SwingUtilities.replaceUIInputMap(this.jcomp, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT,
            newMap);
}
 
Example 16
public EuropeButton(String text, int keyEvent, String command,
                    ActionListener listener) {
    setOpaque(true);
    setText(text);
    setActionCommand(command);
    addActionListener(listener);
    InputMap closeInputMap = new ComponentInputMap(this);
    closeInputMap.put(KeyStroke.getKeyStroke(keyEvent, 0, false),
                      "pressed");
    closeInputMap.put(KeyStroke.getKeyStroke(keyEvent, 0, true),
                      "released");
    SwingUtilities.replaceUIInputMap(this,
                                     JComponent.WHEN_IN_FOCUSED_WINDOW,
                                     closeInputMap);
}
 
Example 17
protected void uninstallKeyboardActions() {
  SwingUtilities.replaceUIActionMap(lizziePane, null);
  SwingUtilities.replaceUIInputMap(
      lizziePane, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, null);
}
 
Example 18
Source Project: iBioSim   File: CloseTabPaneUI.java    License: Apache License 2.0 4 votes vote down vote up
@Override
protected void uninstallKeyboardActions() {
	SwingUtilities.replaceUIActionMap(tabPane, null);
	SwingUtilities.replaceUIInputMap(tabPane, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, null);
	SwingUtilities.replaceUIInputMap(tabPane, JComponent.WHEN_FOCUSED, null);
}
 
Example 19
protected void uninstallKeyboardActions()
{
  SwingUtilities.replaceUIInputMap(terminal, JComponent.WHEN_FOCUSED, null);
  SwingUtilities.replaceUIActionMap(terminal, null);
}
 
Example 20
Source Project: netbeans   File: BaseTextUI.java    License: Apache License 2.0 4 votes vote down vote up
/** Installs the UI for a component. */
public @Override void installUI(JComponent c) {
    super.installUI(c);
    
    if (!(c instanceof JTextComponent)) {
        return;
    }
    
    JTextComponent component = getComponent();
    prefs = MimeLookup.getLookup(org.netbeans.lib.editor.util.swing.DocumentUtilities.getMimeType(component)).lookup(Preferences.class);

    
    // set margin
    String value = prefs.get(SimpleValueNames.MARGIN, null);
    Insets margin = value != null ? SettingsConversions.parseInsets(value) : null;
    component.setMargin(margin != null ? margin : EditorUI.NULL_INSETS);

    getEditorUI().installUI(component);
    
    // attach to the model and component
    //component.addPropertyChangeListener(this); already done in super class
    if (component.getClientProperty(UIWatcher.class) == null) {
        UIWatcher uiWatcher = new UIWatcher(this.getClass());
        component.addPropertyChangeListener(uiWatcher);
        component.putClientProperty(UIWatcher.class, uiWatcher);
    }
    
    BaseKit kit = (BaseKit)getEditorKit(component);
    ViewFactory vf = kit.getViewFactory();
    // Create and attach caret
    Caret defaultCaret = component.getCaret();
    Caret caret = kit.createCaret();
    component.setCaretColor(Color.black); // will be changed by settings later
    component.setCaret(caret);
    component.putClientProperty(PROP_DEFAULT_CARET_BLINK_RATE, defaultCaret.getBlinkRate());
    component.setKeymap(kit.getKeymap());
    
    // assign blink rate
    int br = prefs.getInt(SimpleValueNames.CARET_BLINK_RATE, -1);
    if (br == -1) {
        br = defaultCaret.getBlinkRate();
    }
    caret.setBlinkRate(br);

    SwingUtilities.replaceUIInputMap(c, JComponent.WHEN_FOCUSED, null);
    
    EditorApiPackageAccessor.get().register(component);
    component.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
}