Package javax.swing

Examples of javax.swing.InputMap


    contentPane.add(createContentPane(), BorderLayout.CENTER);
    contentPane.add(buttonPanel, BorderLayout.SOUTH);
    setContentPane(contentPane);

    final InputMap inputMap = contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    final ActionMap actionMap = contentPane.getActionMap();

    inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "confirm"); // NON-NLS
    inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "cancel"); // NON-NLS
    actionMap.put("confirm", getConfirmAction()); // NON-NLS
    actionMap.put("cancel", getCancelAction()); // NON-NLS

    resizeDialog();
  }
View Full Code Here


    buttonsPanel.setBorder(BorderFactory.createEmptyBorder(25, 0, 10, 10));

    ActionMap actionMap = buttonsPanel.getActionMap();
    actionMap.put(cancelAction.getValue(Action.DEFAULT), cancelAction);
    actionMap.put(okAction.getValue(Action.DEFAULT), okAction);
    InputMap inputMap = buttonsPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    inputMap.put(KeyStroke.getKeyStroke("ESCAPE"), cancelAction.getValue(Action.DEFAULT));
    inputMap.put(KeyStroke.getKeyStroke("ENTER"), okAction.getValue(Action.DEFAULT));

    JPanel dialogEastPanel = new JPanel();
    dialogEastPanel.setLayout(new BorderLayout());
    dialogEastPanel.add(buttonsPanel, BorderLayout.NORTH);
    dialog.getContentPane().add(this, BorderLayout.CENTER);
View Full Code Here

     * Builds the InputMap of this canvas with a set of predefined
     * <tt>Action</tt>s.
     */
    protected void installKeyboardActions() {

        InputMap inputMap = getInputMap(JComponent.WHEN_FOCUSED);
        KeyStroke key;

        key = KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0);
        inputMap.put(key, SCROLL_RIGHT_ACTION);

        key = KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0);
        inputMap.put(key, SCROLL_LEFT_ACTION);

        key = KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0);
        inputMap.put(key, SCROLL_UP_ACTION);

        key = KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0);
        inputMap.put(key, SCROLL_DOWN_ACTION);

        key = KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, KeyEvent.SHIFT_MASK);
        inputMap.put(key, FAST_SCROLL_RIGHT_ACTION);

        key = KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, KeyEvent.SHIFT_MASK);
        inputMap.put(key, FAST_SCROLL_LEFT_ACTION);

        key = KeyStroke.getKeyStroke(KeyEvent.VK_UP, KeyEvent.SHIFT_MASK);
        inputMap.put(key, FAST_SCROLL_UP_ACTION);

        key = KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, KeyEvent.SHIFT_MASK);
        inputMap.put(key, FAST_SCROLL_DOWN_ACTION);

        key = KeyStroke.getKeyStroke(KeyEvent.VK_I, KeyEvent.CTRL_MASK);
        inputMap.put(key, ZOOM_IN_ACTION);

        key = KeyStroke.getKeyStroke(KeyEvent.VK_O, KeyEvent.CTRL_MASK);
        inputMap.put(key, ZOOM_OUT_ACTION);

        key = KeyStroke.getKeyStroke(KeyEvent.VK_T, KeyEvent.CTRL_MASK);
        inputMap.put(key, RESET_TRANSFORM_ACTION);
    }
View Full Code Here

     * Builds the InputMap of this canvas with a set of predefined
     * <tt>Action</tt>s.
     */
    protected void installKeyboardActions() {

        InputMap inputMap = getInputMap(JComponent.WHEN_FOCUSED);
        KeyStroke key;

        key = KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0);
        inputMap.put(key, SCROLL_RIGHT_ACTION);

        key = KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0);
        inputMap.put(key, SCROLL_LEFT_ACTION);

        key = KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0);
        inputMap.put(key, SCROLL_UP_ACTION);

        key = KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0);
        inputMap.put(key, SCROLL_DOWN_ACTION);

        key = KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, KeyEvent.SHIFT_MASK);
        inputMap.put(key, FAST_SCROLL_RIGHT_ACTION);

        key = KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, KeyEvent.SHIFT_MASK);
        inputMap.put(key, FAST_SCROLL_LEFT_ACTION);

        key = KeyStroke.getKeyStroke(KeyEvent.VK_UP, KeyEvent.SHIFT_MASK);
        inputMap.put(key, FAST_SCROLL_UP_ACTION);

        key = KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, KeyEvent.SHIFT_MASK);
        inputMap.put(key, FAST_SCROLL_DOWN_ACTION);

        key = KeyStroke.getKeyStroke(KeyEvent.VK_I, KeyEvent.CTRL_MASK);
        inputMap.put(key, ZOOM_IN_ACTION);

        key = KeyStroke.getKeyStroke(KeyEvent.VK_O, KeyEvent.CTRL_MASK);
        inputMap.put(key, ZOOM_OUT_ACTION);

        key = KeyStroke.getKeyStroke(KeyEvent.VK_T, KeyEvent.CTRL_MASK);
        inputMap.put(key, RESET_TRANSFORM_ACTION);
    }
View Full Code Here

    harness.check(defaults.get("ScrollPane.ancestorInputMap.RightToLeft") instanceof InputMapUIResource);
    harness.check(defaults.get("ScrollPane.border") instanceof BasicBorders.FieldBorder);
    harness.check(defaults.get("ScrollPane.font"), new FontUIResource("Dialog", Font.PLAIN, 12));
   
    harness.checkPoint("Slider");
    InputMap map = (InputMap) defaults.get("Slider.focusInputMap");
    KeyStroke[] keys = map.keys();
    InputMap focusInputMap = (InputMap) defaults.get("Slider.focusInputMap");
    List keyList = Arrays.asList(keys);
    harness.check(keyList.contains(KeyStroke.getKeyStroke("LEFT")));
    harness.check(keyList.contains(KeyStroke.getKeyStroke("RIGHT")));
    harness.check(keyList.contains(KeyStroke.getKeyStroke("UP")));
    harness.check(keyList.contains(KeyStroke.getKeyStroke("DOWN")))
    harness.check(keyList.contains(KeyStroke.getKeyStroke("KP_LEFT")));
    harness.check(keyList.contains(KeyStroke.getKeyStroke("KP_RIGHT")));
    harness.check(keyList.contains(KeyStroke.getKeyStroke("KP_UP")))
    harness.check(keyList.contains(KeyStroke.getKeyStroke("KP_DOWN")))
    harness.check(keyList.contains(KeyStroke.getKeyStroke("HOME")));
    harness.check(keyList.contains(KeyStroke.getKeyStroke("END")));
    harness.check(keyList.contains(KeyStroke.getKeyStroke("PAGE_UP")));
    harness.check(keyList.contains(KeyStroke.getKeyStroke("PAGE_DOWN")));
    harness.check(focusInputMap.get(KeyStroke.getKeyStroke("LEFT")), "negativeUnitIncrement");
    harness.check(focusInputMap.get(KeyStroke.getKeyStroke("RIGHT")), "positiveUnitIncrement");
    harness.check(focusInputMap.get(KeyStroke.getKeyStroke("UP")), "positiveUnitIncrement");
    harness.check(focusInputMap.get(KeyStroke.getKeyStroke("DOWN")), "negativeUnitIncrement");
    harness.check(focusInputMap.get(KeyStroke.getKeyStroke("KP_LEFT")), "negativeUnitIncrement");
    harness.check(focusInputMap.get(KeyStroke.getKeyStroke("KP_RIGHT")), "positiveUnitIncrement");
    harness.check(focusInputMap.get(KeyStroke.getKeyStroke("KP_UP")), "positiveUnitIncrement");
    harness.check(focusInputMap.get(KeyStroke.getKeyStroke("KP_DOWN")), "negativeUnitIncrement");
    harness.check(focusInputMap.get(KeyStroke.getKeyStroke("HOME")), "minScroll");
    harness.check(focusInputMap.get(KeyStroke.getKeyStroke("END")), "maxScroll");
    harness.check(focusInputMap.get(KeyStroke.getKeyStroke("PAGE_UP")), "positiveBlockIncrement");
    harness.check(focusInputMap.get(KeyStroke.getKeyStroke("PAGE_DOWN")), "negativeBlockIncrement");
   
    InputMap rightToLeftMap = (InputMap) defaults.get("Slider.focusInputMap.RightToLeft");
    keys = rightToLeftMap != null ? rightToLeftMap.keys() : new KeyStroke[] {};
    keyList = Arrays.asList(keys);
    harness.check(keyList.contains(KeyStroke.getKeyStroke("RIGHT")));
    harness.check(keyList.contains(KeyStroke.getKeyStroke("KP_RIGHT")));
    harness.check(keyList.contains(KeyStroke.getKeyStroke("LEFT")));
    harness.check(keyList.contains(KeyStroke.getKeyStroke("KP_LEFT")));
    if (rightToLeftMap == null)
    {
      rightToLeftMap = new InputMap()// to prevent NullPointerException   
    }
    harness.check(rightToLeftMap.get(KeyStroke.getKeyStroke("RIGHT")), "negativeUnitIncrement");
    harness.check(rightToLeftMap.get(KeyStroke.getKeyStroke("KP_RIGHT")), "negativeUnitIncrement");
    harness.check(rightToLeftMap.get(KeyStroke.getKeyStroke("LEFT")), "positiveUnitIncrement");
    harness.check(rightToLeftMap.get(KeyStroke.getKeyStroke("KP_LEFT")), "positiveUnitIncrement");
   
    harness.check(defaults.get("Slider.focusInsets"), new InsetsUIResource(2, 2, 2, 2));
   
    harness.checkPoint("Spinner");
    harness.check(defaults.get("Spinner.ancestorInputMap") instanceof InputMapUIResource);
View Full Code Here

   
  public void testMethod1(TestHarness harness)
  {
    harness.checkPoint("()");
    JScrollBar sb = new JScrollBar();
    InputMap m1 = sb.getInputMap();
    InputMap m2 = sb.getInputMap(JComponent.WHEN_FOCUSED);  
    harness.check(m1 == m2);
  }
View Full Code Here

   
  public void testMethod2(TestHarness harness)
  {
    harness.checkPoint("(int)");
    JScrollBar sb = new JScrollBar();
    InputMap m1 = sb.getInputMap(JComponent.WHEN_FOCUSED);
    harness.check(m1.keys(), null);
    InputMap m1p = m1.getParent();
    harness.check(m1p, null);
    InputMap m2 = sb.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);  
    harness.check(m2.keys(), null);
    InputMap m2p = m2.getParent();
    harness.check(m2p.get(KeyStroke.getKeyStroke("pressed PAGE_UP")), "negativeBlockIncrement");
    harness.check(m2p.get(KeyStroke.getKeyStroke("pressed PAGE_DOWN")), "positiveBlockIncrement");
    harness.check(m2p.get(KeyStroke.getKeyStroke("pressed END")), "maxScroll");
    harness.check(m2p.get(KeyStroke.getKeyStroke("pressed HOME")), "minScroll");
    harness.check(m2p.get(KeyStroke.getKeyStroke("pressed LEFT")), "negativeUnitIncrement");
    harness.check(m2p.get(KeyStroke.getKeyStroke("pressed KP_UP")), "negativeUnitIncrement");
    harness.check(m2p.get(KeyStroke.getKeyStroke("pressed KP_DOWN")), "positiveUnitIncrement");
    harness.check(m2p.get(KeyStroke.getKeyStroke("pressed UP")), "negativeUnitIncrement");
    harness.check(m2p.get(KeyStroke.getKeyStroke("pressed RIGHT")), "positiveUnitIncrement");
    harness.check(m2p.get(KeyStroke.getKeyStroke("pressed KP_LEFT")), "negativeUnitIncrement");
    harness.check(m2p.get(KeyStroke.getKeyStroke("pressed DOWN")), "positiveUnitIncrement");
    harness.check(m2p.get(KeyStroke.getKeyStroke("pressed KP_RIGHT")), "positiveUnitIncrement");

    InputMap m3 = sb.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    harness.check(m3.keys(), null);
    harness.check(m3.getParent(), null);
  }
View Full Code Here

   
  public void testMethod1(TestHarness harness)
  {
    harness.checkPoint("()");
    JTabbedPane tp = new JTabbedPane();
    InputMap m1 = tp.getInputMap();
    InputMap m2 = tp.getInputMap(JComponent.WHEN_FOCUSED);  
    harness.check(m1 == m2);
  }
View Full Code Here

   
  public void testMethod2(TestHarness harness)
  {
    harness.checkPoint("(int)");
    JTabbedPane tp = new JTabbedPane();
    InputMap m1 = tp.getInputMap(JComponent.WHEN_FOCUSED);
    harness.check(m1.keys(), null);
    InputMap m1p = m1.getParent();
    harness.check(m1p.get(KeyStroke.getKeyStroke("ctrl pressed DOWN")),
            "requestFocusForVisibleComponent");
    harness.check(m1p.get(KeyStroke.getKeyStroke("pressed KP_UP")),
            "navigateUp");
    harness.check(m1p.get(KeyStroke.getKeyStroke("pressed LEFT")),
            "navigateLeft");
    harness.check(m1p.get(KeyStroke.getKeyStroke("ctrl pressed KP_DOWN")),
            "requestFocusForVisibleComponent");
    harness.check(m1p.get(KeyStroke.getKeyStroke("pressed UP")), "navigateUp");
    harness.check(m1p.get(KeyStroke.getKeyStroke("pressed KP_DOWN")),
            "navigateDown");
    harness.check(m1p.get(KeyStroke.getKeyStroke("pressed KP_LEFT")),
            "navigateLeft");
    harness.check(m1p.get(KeyStroke.getKeyStroke("pressed RIGHT")),
            "navigateRight");
    harness.check(m1p.get(KeyStroke.getKeyStroke("pressed KP_RIGHT")),
            "navigateRight");
    harness.check(m1p.get(KeyStroke.getKeyStroke("pressed DOWN")),
            "navigateDown");
    InputMap m2 = tp.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);  
    harness.check(m2.keys(), null);
    InputMap m2p = m2.getParent();
    harness.check(m2p.get(KeyStroke.getKeyStroke("ctrl pressed PAGE_DOWN")),
            "navigatePageDown");
    harness.check(m2p.get(KeyStroke.getKeyStroke("ctrl pressed PAGE_UP")),
            "navigatePageUp");
    harness.check(m2p.get(KeyStroke.getKeyStroke("ctrl pressed UP")),
            "requestFocus");
    harness.check(m2p.get(KeyStroke.getKeyStroke("ctrl pressed KP_UP")),
            "requestFocus");
    InputMap m3 = tp.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    harness.check(m3.keys(), null);
    harness.check(m3.getParent(), null);
  }
View Full Code Here

   
    harness.checkPoint("Slider");
    harness.check(defaults.get("Slider.altTrackColor"), null);
    harness.check(defaults.get("Slider.background"), new ColorUIResource(0, 0, 4));
    harness.check(defaults.get("Slider.focus"), new ColorUIResource(0, 0, 12));
    InputMap focusInputMap = (InputMap) defaults.get("Slider.focusInputMap");
    KeyStroke[] keys = focusInputMap.keys();
//    for (int i = 0; i < keys.length; i++) {
//        System.out.println(keys[i] + " --> " + focusInputMap.get(keys[i]));
//    }
    List keyList = Arrays.asList(keys);
    harness.check(keyList.contains(KeyStroke.getKeyStroke("LEFT")));
    harness.check(keyList.contains(KeyStroke.getKeyStroke("RIGHT")));
    harness.check(keyList.contains(KeyStroke.getKeyStroke("UP")));
    harness.check(keyList.contains(KeyStroke.getKeyStroke("DOWN")))
    harness.check(keyList.contains(KeyStroke.getKeyStroke("KP_LEFT")));
    harness.check(keyList.contains(KeyStroke.getKeyStroke("KP_RIGHT")));
    harness.check(keyList.contains(KeyStroke.getKeyStroke("KP_UP")))
    harness.check(keyList.contains(KeyStroke.getKeyStroke("KP_DOWN")))
    harness.check(keyList.contains(KeyStroke.getKeyStroke("HOME")));
    harness.check(keyList.contains(KeyStroke.getKeyStroke("END")));
    harness.check(keyList.contains(KeyStroke.getKeyStroke("PAGE_UP")));
    harness.check(keyList.contains(KeyStroke.getKeyStroke("PAGE_DOWN")));
    harness.check(keyList.contains(KeyStroke.getKeyStroke("ctrl PAGE_DOWN")));
    harness.check(keyList.contains(KeyStroke.getKeyStroke("ctrl PAGE_UP")))
    harness.check(focusInputMap.get(KeyStroke.getKeyStroke("LEFT")), "negativeUnitIncrement");
    harness.check(focusInputMap.get(KeyStroke.getKeyStroke("RIGHT")), "positiveUnitIncrement");
    harness.check(focusInputMap.get(KeyStroke.getKeyStroke("UP")), "positiveUnitIncrement");
    harness.check(focusInputMap.get(KeyStroke.getKeyStroke("DOWN")), "negativeUnitIncrement");
    harness.check(focusInputMap.get(KeyStroke.getKeyStroke("KP_LEFT")), "negativeUnitIncrement");
    harness.check(focusInputMap.get(KeyStroke.getKeyStroke("KP_RIGHT")), "positiveUnitIncrement");
    harness.check(focusInputMap.get(KeyStroke.getKeyStroke("KP_UP")), "positiveUnitIncrement");
    harness.check(focusInputMap.get(KeyStroke.getKeyStroke("KP_DOWN")), "negativeUnitIncrement");
    harness.check(focusInputMap.get(KeyStroke.getKeyStroke("HOME")), "minScroll");
    harness.check(focusInputMap.get(KeyStroke.getKeyStroke("END")), "maxScroll");
    harness.check(focusInputMap.get(KeyStroke.getKeyStroke("PAGE_UP")), "positiveBlockIncrement");
    harness.check(focusInputMap.get(KeyStroke.getKeyStroke("PAGE_DOWN")), "negativeBlockIncrement");
    harness.check(focusInputMap.get(KeyStroke.getKeyStroke("ctrl PAGE_DOWN")), "negativeBlockIncrement");
    harness.check(focusInputMap.get(KeyStroke.getKeyStroke("ctrl PAGE_UP")), "positiveBlockIncrement");
   
    InputMap rightToLeftMap = (InputMap) defaults.get("Slider.focusInputMap.RightToLeft");
    keys = rightToLeftMap != null ? rightToLeftMap.keys() : new KeyStroke[] {};
    keyList = Arrays.asList(keys);
//    for (int i = 0; i < keys.length; i++) {
//        System.out.println(keys[i] + " --> " + focusInputMap.get(keys[i]));
//    }
    harness.check(keyList.contains(KeyStroke.getKeyStroke("RIGHT")));
    harness.check(keyList.contains(KeyStroke.getKeyStroke("KP_RIGHT")));
    harness.check(keyList.contains(KeyStroke.getKeyStroke("LEFT")));
    harness.check(keyList.contains(KeyStroke.getKeyStroke("KP_LEFT")));
    if (rightToLeftMap == null)
    {
      rightToLeftMap = new InputMap()// to prevent NullPointerException   
    }
    harness.check(rightToLeftMap.get(KeyStroke.getKeyStroke("RIGHT")), "negativeUnitIncrement");
    harness.check(rightToLeftMap.get(KeyStroke.getKeyStroke("KP_RIGHT")), "negativeUnitIncrement");
    harness.check(rightToLeftMap.get(KeyStroke.getKeyStroke("LEFT")), "positiveUnitIncrement");
    harness.check(rightToLeftMap.get(KeyStroke.getKeyStroke("KP_LEFT")), "positiveUnitIncrement");
   
    harness.check(defaults.get("Slider.focusInsets"), new InsetsUIResource(0, 0, 0, 0));
    harness.check(defaults.get("Slider.foreground"), new ColorUIResource(0, 0, 24));
    harness.check(defaults.get("Slider.highlight"), new ColorUIResource(0, 0, 7));
    harness.check(defaults.get("Slider.horizontalThumbIcon") != null);
View Full Code Here

TOP

Related Classes of javax.swing.InputMap

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.