Is this your first time here? SwingWiki is a Java Swing Developer community site with an big archive of Swing-related usenet groups and mailing lists, but also tips, tricks and articles and book reviews written by your colleagues from around the world. If you came here through a search engine and did not find what you were looking for, make sure to check the wiki table of contents.

Global F1 help key

F1 key usually displays help in any context. Classic Swing action model would require that you set a key listener for all components on the screen. If you use input maps, you can install a central listener for all components inside a frame. This code installs a listener for F1 for all components in top-level JComponent (you cannot use this with a a JFrame, but can attach actions to the content panel of a JFrame - for a full example, see interacting with users):

    KeyStroke ks=KeyStroke.getKeyStroke(KeyEvent.VK_F1,0);
    topComponent.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(ks,"HELP");
    topComponent.getActionMap().put("HELP",new AbstractAction(){
         public void actionPerformed(ActionEvent evt){
         // do something here, display a dialog or whatever
    });
 

Comments? Corrections? Contact us or Login to edit pages directly (registration is free and takes less than displaying a JLabel)
  howto/f1_help.txt · Last modified: 2006/09/14 18:59 by 86.133.133.175 (gojko)
 
Recent changes | RSS changes | Table of contents | News Archive | Terms And Conditions | Register | The Quest For Software++| Ruby Resources

Sedo - Buy and Sell Domain Names and Websites project info: swingwiki.org Statistics for project swingwiki.org etracker� web controlling instead of log file analysis