Package javax.swing

Examples of javax.swing.KeyStroke


        public void onCloseRequest() {
          hideFindBox();
        }
      });
      top.add(closeButton);
      KeyStroke key = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
      getInputMap(WHEN_IN_FOCUSED_WINDOW).put(key, "find-cancel");
      key = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
      getInputMap(WHEN_IN_FOCUSED_WINDOW).put(key, "find-search");
      getActionMap().put("find-search", new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
View Full Code Here


     * <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);
View Full Code Here

     * <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);
View Full Code Here

    }
  }
  public void test(TestHarness harness)
  {
    MyJComponent c = new MyJComponent();
    KeyStroke ks = KeyStroke.getKeyStroke('a');
    ActionListener a1 = new ActionListener()
    {
      public void actionPerformed(ActionEvent e)
      {
        // ignore
View Full Code Here

public class get implements Testlet
{
  public void test(TestHarness harness)
  {
    InputMap m = new InputMap();
    KeyStroke ks1 = KeyStroke.getKeyStroke('a');
    harness.check(m.get(ks1), null);
    m.put(ks1, "ABC");
    harness.check(m.get(ks1), "ABC");
   
    harness.check(m.get(null), null);
   
    // check that a binding in the parent is found
    InputMap p = new InputMap();
    KeyStroke ks2 = KeyStroke.getKeyStroke('b');
    p.put(ks2, "XYZ");
    m.setParent(p);
    harness.check(m.get(ks2), "XYZ");
  }
View Full Code Here

public class put implements Testlet
{
  public void test(TestHarness harness)
  {
    InputMap m = new InputMap();
    KeyStroke ks1 = KeyStroke.getKeyStroke('a');
    m.put(ks1, "ABC");
    harness.check(m.get(ks1), "ABC");
    m.put(ks1, "DEF");
    harness.check(m.get(ks1), "DEF");
    m.put(ks1, null);
View Full Code Here

public class remove implements Testlet
{
  public void test(TestHarness harness)
  {
    InputMap m = new InputMap();
    KeyStroke ks1 = KeyStroke.getKeyStroke('a');
   
    // try removing from an empty map
    m.remove(ks1);
    harness.check(m.get(ks1), null);
   
    // add and remove
    m.put(ks1, "ABC");
    harness.check(m.get(ks1), "ABC");
    m.remove(ks1);
    harness.check(m.get(ks1), null);
   
    // try removing null
    m.remove(null);
    harness.check(m.size(), 0);
    m.put(ks1, "ABC");
    m.remove(null);
    harness.check(m.size(), 1);
   
    // confirm that remove doesn't affect the parent
    KeyStroke ks2 = KeyStroke.getKeyStroke('b');
    InputMap p = new InputMap();
    p.put(ks2, "ZZZ");
    m.setParent(p);
    m.remove(ks2);
    harness.check(m.get(ks2), "ZZZ");
View Full Code Here

{
  public void test(TestHarness harness)
  {
    InputMap m = new InputMap();
    harness.check(m.allKeys(), null);
    KeyStroke ks1 = KeyStroke.getKeyStroke('a');
    m.put(ks1, "AAA");
    KeyStroke[] keys = m.allKeys();
    harness.check(keys.length, 1);
    harness.check(keys[0], ks1);
   
    InputMap p = new InputMap();
    m.setParent(p);
    keys = m.allKeys();
    harness.check(keys.length, 1);
    harness.check(keys[0], ks1);
   
    KeyStroke ks2 = KeyStroke.getKeyStroke('b');
    p.put(ks2, "BBB");
    keys = m.allKeys();
    harness.check(keys.length, 2);
    harness.check(keys[0], ks2);
    harness.check(keys[1], ks1);
   
    // try a KeyStroke that is defined in both maps
    KeyStroke ks3 = KeyStroke.getKeyStroke('z');
    p.put(ks3, "ZZZ");
    m.put(ks3, "XXX");
    keys = m.allKeys();
    harness.check(keys.length, 3);
    harness.check(keys[0], ks2);
View Full Code Here

  }
  public void test(TestHarness harness)
  {
    JComponent c = new MyJComponent();
    harness.check(c.getRegisteredKeyStrokes().length, 0);
    KeyStroke ks0 = KeyStroke.getKeyStroke('a');
    KeyStroke ks1 = KeyStroke.getKeyStroke('b');
    KeyStroke ks2 = KeyStroke.getKeyStroke('c');;
    c.getInputMap(JComponent.WHEN_FOCUSED).put(ks0, "A");
    harness.check(c.getRegisteredKeyStrokes()[0], ks0);
    c.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(ks1, "B");
    harness.check(c.getRegisteredKeyStrokes()[0], ks0);
    harness.check(c.getRegisteredKeyStrokes()[1], ks1);
View Full Code Here

        //System.out.println("got a go...");
        GoButtonPressed();
      }
    };

    KeyStroke keystroke =
      KeyStroke.getKeyStroke('g');//, java.awt.event.InputEvent.CTRL_MASK);
    mainGuiPanel.getInputMap().put(keystroke, "go");
    mainGuiPanel.getActionMap().put("go", goAction);

    Color c = new Color((int)(Math.random() * 127 + 127),
View Full Code Here

TOP

Related Classes of javax.swing.KeyStroke

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.