Skip to main content

Cannot get enableHelpKey to respond to F1 clicks

1 reply [Last post]
coryb891
Offline
Joined: 2010-06-28

I am attempting to follow the JavaHelp 2.0 guide and demo programs (specifically idedemo) as best I can, however I have been unsuccessful in getting my JFrame window (ViewerMain) to show the help window when F1 is clicked. This is the code that I have located within the JFrame subclass's constructor:

ClassLoader cl = ViewerMain.class.getClassLoader();
try {
URL hsUrl = HelpSet.findHelpSet(cl, "DavisHelp.hs");
mainHS = new HelpSet(cl, hsUrl);
} catch(Exception e) {
JOptionPane.showConfirmDialog(this, "Unable to load DavisHelp.hs", "Error",
JOptionPane.OK_OPTION, JOptionPane.ERROR_MESSAGE);
}

if(mainHS != null) {
mainHB = mainHS.createHelpBroker();

mainHB.enableHelpKey(this.getRootPane(), "top", null);

JMenuItem helpMenuItem = new JMenuItem("Help");
mainHB.enableHelpOnButton(helpMenuItem, "top", null);
help.add(helpMenuItem);
}

The "Help" menu item works correctly and shows the help window, but pressing F1 does not. Am I missing something?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
coryb891
Offline
Joined: 2010-06-28

Problem solved. The ViewerMain class extended JFrame, but was not being used as a JFrame at all and was never even being displayed. Instead, it contained a JFrame member variable that was displayed on the screen. Somehow, somebody changed the way the main window was setup and forgot to remove the "extends JFrame". :-S Calling enableKeyHelp using the member variable frame worked fine.