Swing By Iqtidar Ali
Background of Swing We have been looking at AWT (Abstract Window ToolKit) components up till now. Programmers were not comfortable when doing programming with AWT. Bcoz AWT is limited range. Has lots of Bugs. Takes up lots of System Resources.
Swing JAVA provides a rich set of libraries to create Graphical User Interface. Swing provides more features for programming. It added plenty of sophisticated components for programmers use. It takes less system resources. Swing has 4 times more components as AWT.
Swing Swing is a part of the java Foundation Classes (JFC) Library. JFC is an extension of the Abstract Window Toolkit (AWT). JFC provides improved functionality over the AWT. Like New Component, New Features in Existing Components, Better Event handling. Light Weight, Rich controls, Highly Customizable, Pluggable lookand-feel. The Swing GUI components have names beginning with the letter J e.g., JButton, JLabel etc.
Major Components of Swing As Swing is built on top of the AWT packages so Swing consist of a great number of pre-built classes. They have basically same name as that of AWT classes. The letter J has been added to it in beginning. E.g., JApplet, JButton, JCheckbox, JFrame, JLabel, JTree, etc.
GUI (Graphical User Interface) GUI is a visual interface to a program. GUI are built from GUI components. A GUI component is an object with which the user interacts via of mouse or keyboard. The java.awt or javax.swing package, Both these packages provide rich set of user interface component.
Java.awt packages AWT the Abstract Window Toolkit. It contains original GUI components that came with the first release of JDK. AWT components are called Heavy Weight Component as they rely on local platform. when AWT is created corresponding process on the O.S is created which make it heavy.
Javax.Swing packages These are the newest GUI components. As Swing components are written, manipulated and displayed completely in java. That s why its called pure java components. The swing components allow the programmer to specify a uniform look & feel across all platforms. Swing components are referred as light weight components. Several swing components are still HWC (Heavy Weight Component)
User Interface Every user interface considers the following three main aspects: UI elements : These are the core visual elements the user eventually sees and interacts with GWT provides a huge list of widely used and common elements varying from basic to complex. Layouts: They define how UI elements should be organized on the screen and provide a final look and feel to the GUI (Graphical User Interface). Behaviour: These are events which occur when the user interacts with UI elements. The behaviour part will be covered in Event Handling.
Java Swing class hierarchy
Component A Container is the abstract base class for the non menu user-interface controls of SWING. Component represents an object with graphical representation. Container A Container is a component that can contain other SWING components. JComponent A JComponent is a base class for all swing UI components. In order to use a swing component that inherits from JComponent. component must be in a containment hierarchy whose root is a top-level Swing container
SWING UI Elements: Following is the list of commonly used controls while designed GUI using SWING. Control & Description JLabel A JLabel object is a component for placing text in a container. Jbutton This class creates a labeled button. JColorChooser A JColorChooser provides a pane of controls designed to allow a user to manipulate and select a color. JCheck Box A JCheckBox is a graphical component that can be in either an on (true) or off (false) state. JRadioButton The JRadioButton class is a graphical component that can be in either an on (true) or off(false) state. in a group.
SWING UI Elements: Control & Description (Cont--) JList A JList component presents the user with a scrolling list of text items. JComboBox A JComboBox component presents the user with a to show up menu of choices. JTextField A JTextField object is a text component that allows for the editing of a single line of text. JPasswordField A JPasswordField object is a text component specialized for password entry. JTextArea, ImageIcon, Jscrollbar, JOptionPane, JFileChooser, JProgressBar, Jslider, JSpinner
THE END