Programming Examples

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

Tag Archive for ‘ActionEvent’

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 →

JMenuBar, JMenu, JMenuItem

Java Swing JMenu, JMenuItem - Example

This example has a JMenuBar with two JMenu in it. The menus are File and Edit. File Menu has 4 MenuItems which include a JSeparator. This separator is separating Open, Save menu items with the Exit menu items. When you click Open MenuItem under the File Menu, a dialog will be displayed. This helps us to learn how to respond to the Menu Item click event. The Edit menu has 3 Menu Items. Now let us code this example.

Continue Reading →

JButton and ActionListener

JButton Example

It is a simple example which has only two components in it. One is JButton and the other one JLabel. When user clicks the Flip Mode button, the Label changes its caption from Read Mode to Write Mode. Upon clicking the button again, the label restores its original caption Read Mode. So during each click, the Label will alternate between the text Read Mode & Write Mode. Let us proceed with the coding:

Continue Reading →