Package javax.swing

Examples of javax.swing.InputMap


public class getParent implements Testlet
{
  public void test(TestHarness harness)
  {
    InputMap m = new InputMap();
    harness.check(m.getParent(), null);
    InputMap p = new InputMap();
    m.setParent(p);
    harness.check(m.getParent(), p);
    m.setParent(null);
    harness.check(m.getParent(), null);
  }
View Full Code Here


public class constructor implements Testlet
{
  public void test(TestHarness harness)
  {
    InputMap m = new InputMap();
    harness.check(m.size(), 0);
    harness.check(m.getParent(), null);
    harness.check(m.keys(), null);
    harness.check(m.allKeys(), null);
  }
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);
    harness.check(m.get(ks1), null);
    harness.check(m.size(), 0);
   
    // try null key
    m.put(null, "ZZZ");
    harness.check(m.get(null), null);
  }
View Full Code Here

public class keys implements Testlet
{
  public void test(TestHarness harness)
  {
    InputMap map = new InputMap();
    KeyStroke[] k = map.keys();
    harness.check(k, null);
    map.put(KeyStroke.getKeyStroke('a'), "AAA");
    k = map.keys();
    harness.check(k.length, 1);
    harness.check(k[0], KeyStroke.getKeyStroke('a'));
    map.put(KeyStroke.getKeyStroke('b'), "BBB");
    k = map.keys();
    harness.check(k.length, 2);
    harness.check(k[1], KeyStroke.getKeyStroke('b'));
    map.put(KeyStroke.getKeyStroke('b'), null);
    k = map.keys();
    harness.check(k.length, 1);
    harness.check(k[0], KeyStroke.getKeyStroke('a'));   
    map.clear();
    k = map.keys();
    harness.check(k.length, 0);
   
    // check that no keys from the parent are used
    InputMap p = new InputMap();
    p.put(KeyStroke.getKeyStroke('z'), "ZZZ");
    map.setParent(p);
    k = map.keys();
    harness.check(k.length, 0);
  }
View Full Code Here

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

* This tests whether keys() and allKeys() return null for new InputMaps.
*/
public class newMapKeysNull implements Testlet {
 
  public void test(TestHarness harness) {
          InputMap map = new InputMap();
          if (map.keys() != null)
            harness.fail("New InputMap should return null for keys()");
          if (map.allKeys() != null)
            harness.fail("New ActionMap should return null for allKeys()");
  }
View Full Code Here

   
  public void testMethod2(TestHarness harness)
  {
    harness.checkPoint("(int)");
    JPopupMenu p = new JPopupMenu();
    InputMap m1 = p.getInputMap(JComponent.WHEN_FOCUSED);
    harness.check(m1.keys(), null);
    InputMap m1p = m1.getParent();
    harness.check(m1p, null);
    InputMap m2 = p.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);  
    harness.check(m2.keys(), null);
    harness.check(m2.getParent(), null);
    InputMap m3 = p.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    harness.check(m3.keys(), null);
    harness.check(m3.getParent(), null);
//    InputMap m3p = m3.getParent();
//    harness.check(m3p.get(KeyStroke.getKeyStroke("pressed ESCAPE")), "close");
//    for (int i = 0; i < m3p.keys().length; i++)
//    {
//      System.out.println(m3p.keys()[i] + ", " + m3p.get(m3p.keys()[i]));
View Full Code Here

public class clear implements Testlet
{
  public void test(TestHarness harness)
  {
    InputMap m = new InputMap();
    m.clear();
    harness.check(m.size(), 0);
    m.put(KeyStroke.getKeyStroke('a'), "AAA");
    harness.check(m.size(), 1);
    m.clear();
    harness.check(m.size(), 0);
   
    // confirm that this method doesn't change the parent
    InputMap p = new InputMap();
    p.put(KeyStroke.getKeyStroke('z'), "ZZZ");
    harness.check(p.size(), 1);
    m.setParent(p);
    m.clear();
    harness.check(p.size(), 1);
  }
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 class allKeys implements Testlet
{
  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);
    harness.check(keys[1], ks3);
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.