Programming Examples

Are you a Programmer or Application Developer or a DBA? Take a cup of coffee, sit back and spend few minutes here :)

Swing

JDestopPane & JInternalFrame in Java Swing

JDesktopPane and JInternalPane Example

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.

Continue Reading →

JToolBar – Floating & Docking

Java Swing JToolbar Example

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.

Continue Reading →

JMenu Mnemonic & Accelerator

JMenu Mnemonic and Accelerator

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.

Continue Reading →

JCheckBoxMenuItem & Checked

Java Swing JCheckBox MenuItem 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.

Continue Reading →