Return to Snippet

Revision: 4114
at October 25, 2007 11:33 by mehlam2


Updated Code
public void setBindings(JFrame mainFrame){
  JComponent c = mainFrame.getRootPane();
  c.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_O , InputEvent.CTRL_DOWN_MASK), "open project");
  c.getActionMap().put("open project", new OpenProjectAction());
}

Revision: 4113
at October 25, 2007 11:33 by mehlam2


Updated Code
public void setBindings(JFrame mainFrame){

  JComponent c = mainFrame.getRootPane();
  c.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_O , InputEvent.CTRL_DOWN_MASK), "open project");
 c.getActionMap().put("open project", new OpenProjectAction());
}

Revision: 4112
at October 25, 2007 11:31 by mehlam2


Updated Code
JComponent c = getRootPane();
c.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_O , InputEvent.CTRL_DOWN_MASK), "open project");
c.getActionMap().put("open project", new OpenProjectAction());

Revision: 4111
at October 25, 2007 11:31 by mehlam2


Updated Code
JComponent c = getRootPane();
		c.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_O , InputEvent.CTRL_DOWN_MASK), "open project");
		c.getActionMap().put("open project", new OpenProjectAction());

Revision: 4110
at October 25, 2007 11:29 by mehlam2


Initial Code
public static void main(String[] args) {
        KeyStroke ks = KeyStroke.getKeyStroke("ESCAPE");
        Action action = new ActionExample();
        Object binding = action.getValue(NAME);
 
        JDialog w = new JDialog((JFrame) null, "ActionExample");
        JComponent comp = w.getRootPane();
        comp.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(ks, binding);
        comp.getActionMap().put(binding, action);
}

Initial URL

                                

Initial Description

                                

Initial Title
Assigning key bindings and setting them

Initial Tags
java

Initial Language
Java