Sunday, 27 January 2013

Graphical User Interface (GUI) Components



Input and output dialog boxes can be used to input data into a program and show the output of a program.  The methods showInputDialog and showMessageDialog found in the class JOptionPane of package javax.swing could be used to perform this task.  These methods however have only displayed one dialog box at a time.  A program that will display all input and output in one dialog box is called a Graphical User Interface (GUI).  With a GUI, a user can see inputs and outputs simultaneously, as well as change input values to recalculate output values.

In a Java GUI, the areas used to get input and show results are called JTextFields.  The labels for these text fields are called JLabels, the buttons that calculate output or close the GUI are called JButtons, and the window containing all these components is called JFrame.

The GUI components are places in an area called the content pane of the window.  When a button in the content pane is clicked an event has occurred. The Java system is very prompt in listening for the events generated by a program and then reacting to those events.

No comments:

Post a Comment