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 ‘itemStateChanged’

Swing JComboBox & ItemListener

Java Swing - JComboBox Example

The example contains two JLabels, two JTextFields and a JComboBox. Note, the above screen shows Java Swing JComboBox as an editable type. When the user selects an item in the combo box, we show that in the first text box. We also show the past selected item in the Deselected JTextField. A combo box can show only one item once the drop-down is collapsed. So when the user picks an item, in combo box point of view, one item was selected by the user and one was de-selected (the previous one).

Continue Reading →

JRadioButton & ItemListener

JRadioButton Example

Our example shows three radio buttons in a form. A user can select any one of these radio buttons and only one radio button will be in the selected state. Above, the radio button three is in the selected state. When a radio button is in checked (selected) state, our example will flash a message box stating which radio button is in the selected state. Here in this example, we will create all these radio buttons using JRadioButton component of the Java Swing.

Continue Reading →

AWT CheckboxMenuItem Example

AWT CheckboxMenuItem Example

In this example, we will learn how to use AWT CheckboxMenuItem and Menu Separator.

Here, we use our previous example on AWT Menu and change it to create CheckboxMenuItem. We create three checkbox menu items for Circle, Pentagon and Rectangle. In the above picture, we can also see a sunken line running between normal menu items and checked menu items. This line is called a Menu Separator. We create that here as well in this example.

Continue Reading →