Package javax.swing

Examples of javax.swing.InputMap


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


   
  public void testMethod2(TestHarness harness)
  {
    harness.checkPoint("(int)");
    JLabel label = new JLabel("Test");
    InputMap m1 = label.getInputMap(JComponent.WHEN_FOCUSED);
    harness.check(m1.keys(), null);
    InputMap m1p = m1.getParent();
    harness.check(m1p, null);
    InputMap m2 = label.getInputMap(
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);  
    harness.check(m2.keys(), null);
    harness.check(m2.getParent(), null);
    InputMap m3 = label.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    harness.check(m3.keys(), null);
    harness.check(m3.getParent(), null);

    // now make a label that is the label for a component
    JLabel label2 = new JLabel("Test");
    JButton button = new JButton("Target");
    label2.setLabelFor(button);
    label2.setDisplayedMnemonic('A');

    m1 = label2.getInputMap(JComponent.WHEN_FOCUSED);
    harness.check(m1.keys(), null);
    m1p = m1.getParent();
    harness.check(m1p, null);
    m2 = label2.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);  
    harness.check(m2.keys(), null);
    harness.check(m2.getParent(), null);
    m3 = label2.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    harness.check(m3.keys(), null);
    InputMap m3p = m3.getParent();
    harness.check(m3p.get(KeyStroke.getKeyStroke("alt pressed A")), "press");
    label2.setDisplayedMnemonic('B');
    harness.check(m3p.get(KeyStroke.getKeyStroke("alt pressed B")), "press");
  }
View Full Code Here

 
  public void testKeyMap(TestHarness harness)
  {
    JLabel label = new JLabel("ABC");
    label.setDisplayedMnemonic('B');
    InputMap m = label.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    harness.check(m.get(KeyStroke.getKeyStroke(KeyEvent.VK_B,
            KeyEvent.ALT_DOWN_MASK)), null);
    label.setLabelFor(new JButton());
    m = label.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    harness.check(m.get(KeyStroke.getKeyStroke(KeyEvent.VK_B,
            KeyEvent.ALT_DOWN_MASK)), "press")
  }
View Full Code Here

    contentPane.setLayout(new BorderLayout());
    contentPane.add(createParametersPanel(), BorderLayout.CENTER);
    contentPane.add(createButtonsPanel(), BorderLayout.SOUTH);
    setContentPane(contentPane);
   
    final InputMap inputMap = contentPane.getInputMap();
    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", new OkAction()); // NON-NLS
    actionMap.put("cancel", new CancelAction()); // NON-NLS

    setModal(true);
    pack();
View Full Code Here

    pack();


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

    inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "cancel"); // NON-NLS
    actionMap.put("cancel", new CloseActionListener()); // NON-NLS

  }
View Full Code Here

    c.fill = GridBagConstraints.HORIZONTAL;
    getContentPane().add(createButtons(), c);


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

    inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "cancel"); // NON-NLS
    actionMap.put("cancel", new IgnoreAction()); // NON-NLS

  }
View Full Code Here

    }
 
    if( editMarkerPane == null ) {
      final SpringPanel    spring;
      final ActionMap      amap;
      final InputMap      imap;
      JLabel          lb;
      KeyStroke        ks;
      Action          a;

      spring      = new SpringPanel( 4, 2, 4, 2 );
      ggMarkName    = new JTextField( 24 );
//      GUIUtil.setInitialDialogFocus( ggMarkName );  // removes itself automatically
      ggMarkName.addAncestorListener( new AncestorAdapter() {
        public void ancestorAdded( AncestorEvent e ) {
          ggMarkName.requestFocusInWindow();
          ggMarkName.selectAll();
//          c.removeAncestorListener( this );
        }
      });

      // XXX sync
      timeTrans    = new DefaultUnitTranslator();
      ggMarkPos    = new ParamField( timeTrans );
      ggMarkPos.addSpace( ParamSpace.spcTimeHHMMSS );
      ggMarkPos.addSpace( ParamSpace.spcTimeSmps );
      ggMarkPos.addSpace( ParamSpace.spcTimeMillis );
      ggMarkPos.addSpace( ParamSpace.spcTimePercentF );

      lb        = new JLabel( getResourceString( "labelName" ));
//      lb.setLabelFor( ggMarkName );
      spring.gridAdd( lb, 0, 0 );
      spring.gridAdd( ggMarkName, 1, 0 );
      lb        = new JLabel( getResourceString( "labelPosition" ));
//      lb.setLabelFor( ggMarkPos );
      spring.gridAdd( lb, 0, 1 );
      spring.gridAdd( ggMarkPos, 1, 1, -1, 1 );
//      GUIUtil.setDeepFont( spring, null );
      spring.makeCompactGrid();
      editMarkerPane  = new JPanel( new BorderLayout() );
      editMarkerPane.add( spring, BorderLayout.NORTH );
     
      amap      = spring.getActionMap();
      imap      = spring.getInputMap( JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT );
      ks        = KeyStroke.getKeyStroke( KeyEvent.VK_LEFT, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask() );
// XXX DOESN'T WORK ;-(
//      ggMarkName.getInputMap().remove( ks );
      imap.put( ks, "prev" );
      a        = new ActionEditPrev();
//      amap.put( "prev", a );
      ggEditPrev    = new JButton( a );
      amap.put( "prev", new DoClickAction( ggEditPrev ));
      ks        = KeyStroke.getKeyStroke( KeyEvent.VK_RIGHT, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask() );
// XXX DOESN'T WORK ;-(
//      ggMarkName.getInputMap().remove( ks );
      imap.put( ks, "next" );
      a        = new ActionEditNext();
//      amap.put( "next", a );
      ggEditNext    = new JButton( a );
      amap.put( "next", new DoClickAction( ggEditNext ));
     
View Full Code Here

    }
    private static final KeyStroke DELETE = KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0);

    public static void addAction(JComboBox source, javax.swing.Action action) {
        //  Handle enter key
        InputMap im = source.getInputMap();
        im.put(DELETE, DELETE);
        source.getActionMap().put(DELETE, action);
    }
View Full Code Here

        super(parent, modal);
        initComponents();

        // Close the dialog when Esc is pressed
        String cancelName = "cancel";
        InputMap inputMap = getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
        inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), cancelName);
        ActionMap actionMap = getRootPane().getActionMap();
        actionMap.put(cancelName, new AbstractAction() {

            /**
             *
 
View Full Code Here

        pickerMap.put(JXDatePicker.HOME_NAVIGATE_KEY, createHomeAction(false));
        pickerMap.put(JXDatePicker.HOME_COMMIT_KEY, createHomeAction(true));
        TogglePopupAction popupAction = createTogglePopupAction();
        pickerMap.put("TOGGLE_POPUP", popupAction);
       
        InputMap pickerInputMap = datePicker.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
        pickerInputMap.put(KeyStroke.getKeyStroke("ENTER"), JXDatePicker.COMMIT_KEY);
        pickerInputMap.put(KeyStroke.getKeyStroke("ESCAPE"), JXDatePicker.CANCEL_KEY);
        // PENDING: get from LF
        pickerInputMap.put(KeyStroke.getKeyStroke("F5"), JXDatePicker.HOME_COMMIT_KEY);
        pickerInputMap.put(KeyStroke.getKeyStroke("shift F5"), JXDatePicker.HOME_NAVIGATE_KEY);
        pickerInputMap.put(KeyStroke.getKeyStroke("alt DOWN"), "TOGGLE_POPUP");
       
        installLinkPanelKeyboardActions();
    }
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.