Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a Java SwingHelpDemoapp that displays a frame of size 300x200, as shown on

ID: 3824638 • Letter: W

Question

Write a Java SwingHelpDemoapp that displays a frame of size 300x200, as shown on the right, that offers 5 ways to invoke the help system:

(1) “Help!” menu item under the “About” menu;

(2) “Help!” button on the upper right; (3) “Help!”

toolbar button at the bottom; (4) “H” mnemonic key;

and (5) “ctrl-H” accelerator key.

The help system should be implemented as a single helpAction that is an instance of a HelpAction class that extends

AbstractAction, with all properties set as needed. In addition a thumbnail should show “Help about this app”. When invoked, the help system

should print “Help coming soon...” to the console

Explanation / Answer

There are a number of ways to implement concepts of swing in our programs. Starting from the basic, consider the below code-

import javax.swing.*;
public class SwingDemoHelp{
public static void main(String[] args){

JFrame f = new JFrame();

JButton b = new JButton ("Help");
b.setBounds (130,100,100,40);

f.add(b);
f.setSize(300,200);
f.setLayout(null);
f.setVisible(true);
}
}

The above code will display the form having a buttom named Help.