In this example, we will derive from a JInternalFrame to display html content via the JEditorPane. In the bottom, we have JTextField where you can set a title for the JInternalFrame. When you click Show Html, a static html content will be displayed in the JInternalFrame. You can open multiple JInternalFrame. The example shows static html content, but you can extend this example to ask the user to select a Html file from the disc.
This example has two toolbars in it. One is in the top part of the Frame window and other one is in the bottom part. Each of the toolbar contains three buttons on it and each button is assigned with one image icon. Very first button in the top toolbar shows a message when the user clicks it. When we proceed with the example, we will also learn how to use floating toolbar and study rollover behaviour.
The Example has a single JMenu (Fruits) in the menu bar. The Fruits menu contains 4 menu items in which the second menu will invoke a sub-menu. Three items are in the sub-menu. The JMenu fruits is having an underline below the letter F. The same way all its four menu items have an underline in it. For example, to invoke Apple, the user will hit Alt+F+A. The Menu Item Grapes and the menu item Type II contains greyed letters which denote Ctrl+G and Shift+B. For example, a user can invoke the menu item Type II using the keystrokes CTRL & B. Underline denotes Mnemonic and Greyed out letters denotes menu accelerators. Now we will proceed with creating this example.
This example has a fruits menu and a JLabel in the JFrame. The fruit menu contains four Radio button menu items and the user can pick only one among them. In the JLabel, the example displays what menu item is picked by the user. Now, let us create this example.
The example has a menu called fruits. When the user clicks the Fruits menu, they can see four Checkbox menu items along with Image Icons. At the bottom of the screen, there is a text field which reports all the checked check boxes. In the above picture, Banana & Cherry check boxes are checked and hence the text field shows Banana and Cherry in it. When the user clicks a menu item, a check mark appears in the check box, and it disappears when the user clicks it again.