Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Unit 

V: Exploring Swing:  

SWING UI Elements: 

Following is the list of commonly used controls while designed GUI using SWING. 

Sr.  Control & Description 
No. 

1  JLabel 
A JLabel object is a component for placing text in a container. 

2  JButton 
This class creates a labeled button. 

3  JColorChooser 
A JColorChooser provides a pane of controls designed to allow a user to 
manipulate and select a color. 

4  JCheck Box 
A JCheckBox is a graphical component that can be in either an on(true) or off 
(false) state. 

5  JRadioButton 
The JRadioButton class is a graphical component that can be in either an on 
(true) or off (false) state. in a group. 

6  JList 
A JList component presents the user with a scrolling list of text items. 

7  JComboBox 
A JComboBox component presents the user with a to show up menu of choices. 

8  JTextField 
A JTextField object is a text component that allows for the editing of a single line 
of text. 

9  JPasswordField 
A JPasswordField object is a text component specialized for password entry. 

10  JTextArea 
A JTextArea object is a text component that allows for the editing of a multiple 
lines of text. 

11  ImageIcon 
A ImageIcon control is an implementation of the Icon interface that paints Icons 
from Images 

12  JScrollbar 
A Scrollbar control represents a scroll bar component in order to enable user to 
select from range of values. 

13  JOptionPane 
JOptionPane provides set of standard dialog boxes that prompt users for a value 
or informs them of something. 

14  JFileChooser 
A JFileChooser control represents a dialog window from which the user can 
select a file. 

15  JProgressBar 
As the task progresses towards completion, the progress bar displays the task's 
percentage of completion. 

16  JSlider 
A JSlider lets the user graphically select a value by sliding a knob within a 
bounded interval. 

17  JSpinner 
A JSpinner is a single line input field that lets the user select a number or an 
object value from an ordered sequence. 

 
Applet  
A Java applet is a special kind of Java program that a browser enabled with Java technology can download 
from the internet and run. An applet is typically embedded inside a web page and runs in the context of a 
browser. An applet must be a subclass of the ​
java.applet.Applet​
 class. The ​
Applet​
 class provides 
the standard interface between the applet and the browser environment. 
Swing provides a special subclass of the ​
Applet​
 class called ​
javax.swing.JApplet​
. The ​
JApplet 
class should be used for all applets that use Swing components to construct their graphical user interfaces 
(GUIs). 
The browser's Java Plug­in software manages the lifecycle of an applet. 
Use a web server to test the examples in this lesson. The use of local applets is not recommended, and 
local applets are blocked when the security level setting in the Java Control Panel is set to High or Very 
High. 

 
Two Types of Applets 
It is important to state at the outset that there are two varieties of applets. The first are 
those 
based directly on the ​Applet ​ class described in this chapter. These applets use the 
Abstract 
Window Toolkit (AWT) to provide the graphic user interface (or use no GUI at all). 
This 
style of applet has been available since Java was first created. 
The second type of applets are those based on the Swing class ​ JApplet​ . Swing applets 
use 
the Swing classes to provide the GUI. Swing offers a richer and often easier­to­use 
user interface 
than does the AWT. Thus, Swing­based applets are now the most popular. However, 
traditional 
AWT­based applets are still used, especially when only a very simple user interface is 
required. 
Thus, both AWT­ and Swing­based applets are valid. 
Because ​ JApplet ​ inherits ​
Applet​ , all the features of ​
Applet ​
are also available in 
JApplet​ , 
and most of the information in this chapter applies to both types of applets. Therefore, 
even if 
you are interested in only Swing applets, the information in this chapter is still 
relevant and 
necessary. Understand, however, that when creating Swing­based applets, some 
additional 
constraints apply and these are described later in this topic, when Swing is covered 
 

You might also like