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

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 →

JFileChooser – Get Full File Path

JFileChooser Selected File Example

When we launch the example, it will display a frame window with text field. The click of the ellipsis button (…) will open the file open dialog. From the displayed dialog, we can browse through the folders of the PC and pick a specific file on the folder structure. Our example will display the selected file in the text field. This happens only when the user clicks the Open button. When the user clicks the Cancel button, it will not show the picked file in the text field.

Continue Reading →

JSeparator & Control ToolTip

JSeparator and Tooltip Example

Here in this example, we have sample text boxes in the form. The JSeparator of Java Swing splits each of the text boxes. The splitter is in vertical orientation. Then, we will have tooltips for all the text fields in the window. In the above screen, the Data Of Birth text field is displaying the Tooltip for the user.

Continue Reading →