Professional Documents
Culture Documents
Java OOP (Object Oriented Programming) : Programming Department Fifth Stage 2017-2018
Java OOP (Object Oriented Programming) : Programming Department Fifth Stage 2017-2018
Programming)
Programming Department
Fifth stage
2017-2018
Lectured by : Baxan.A.Mahmood
Basic GUI Components
In the part of the course we will look at some basic Graphical
User Interface (GUI) elements in Java. The next few slides
should give a flavor of how GUI elements are created in
Java. First we will look at dialogs in Java. Java includes
.some standard dialogs which we are going to see first
Using JOptionPane class, you can create and customize
several different kinds of dialogs. JOptionPane provides
support for laying out standard dialogs, providing icons,
specifying the dialog's title and text, and customizing the
.button text
2
Basic GUI Components 2
Other features allow you to customize the components
the dialog displays and specify where the dialog
.should appear onscreen
The above class has several methods to create
standard dialogs, the simples of which is the
showMessageDialog method which would create a
simple one-button dialog and display it on the
.screen
3
Basic GUI Components 3
:Here is an example program showing a message dialog
4
Basic GUI Components 5
:The icon can be changed to any of the following
5
Basic GUI Components 6
6
Basic GUI Components 8
: OptionDialog output
The last type of dialog we will look at is the input dialog which
:will prompt the user to enter a string
;String s=JOptionPane.showInputDialog(null, "What's your name")
7
Basic GUI Components 9
8
Basic GUI Components 10