0% found this document useful (0 votes)
26 views2 pages

OOP CH 5

Os

Uploaded by

Black Adam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views2 pages

OOP CH 5

Os

Uploaded by

Black Adam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

OOP’s_ch_4 :User Interface with AWT and Swing

• Every user interface considers the following three main aspects: UI elements, Layouts, Behavior.
• The Abstract Window Toolkit (AWT) is Java's original platform-dependent windowing, graphics, and user-
interface widget toolkit.
• The AWT is part of theJava Foundation Classes (JFC) .
What is AWT? :
• The Java programming language class library provides a user interface toolkit called the Abstract Window
Toolkit, or the AWT.
•Java AWT is an API to develop GUI or window-based application in Java.
• Java AWT components are platform-dependent.
• The AWT is now part of the Java Foundation Classes (JFC) is the standard API for providing a Graphical
User Interface (GUI) for a Java program.
• The AWT classes are contained in the java.awt package. It is one of Java’s largest packages.
What is Swing? :
• Swing is a GUI widget toolkit for Java.
• It is part of Oracle's Java Foundation Classes (JFC)- is the API for providing a Graphical User Interface (GUI)
for Java programs.
• The swing components are defined in the package javax.swing. This package provides more powerful and
Mr

flexible components
• Swing is a Java foundation classes, library and it is has extension to do Abstract Window Toolkit (AWT).
• Various features of swing are:
Light Weight, Rich Controls, Borders, Easy mouseless Operation, Tooltips, Easy Scrolling, Highly
.R

Customizable,

Sr. No. AWT Swing


1. AWT components are platform dependent. Java swing components are platformindependent.
oh

2. AWT components are heavy weight. Swing components are light weight.
3. AWT doesn't support pluggable look and feel. Swing supports pluggable look and feel.

4. AWT provides less components than Swing. Swing provides more powerful com-
it

ponents such as tables, lists, scrollpanes, colorchooser,


tabbedpane etc.
5. AWT components require java.awt package. Swing components require javax.swing package.

6. Advanced features is not available in AWT. Swing has many advanced features like JTabel, Jtabbed
pane which is not available in AWT.
7. Different looked feel feature is not supported in AWT. We can have different look and feel in Swing.

8. Using AWT, we have to implement a lot of things ourself. Swing has them built in.

LAYOUTS AND LAYOUT MANAGERS :


• Layout means the arrangement of components within the container.
• In other way we can say that placing the components at a particular position within the container.
• Layout manager is an object which determines the way that components are arranged in a frame window.
• A layout manager automatically arranges our controls within a window by using some type of algorithm.
• A layout manager is an instance of any class that implements the LayoutManager interface.
• The layout manager is set by the setLayout() method.
• Each layout manager keeps track of a list of components that are stored by their names
• The layout manager automatically positions all the components within the container.
• A check box is a control that is used to turn an option on (true) or off (false). It consists of a small box that can
either contain a check mark or not.
• Listclass provides a list of items, which can be scrolled. From list of items, single or multiple items can be selected.
•A menu bar displays a list of top-level menu choices. Each choice is associated with a dropdown menu.
• The JButton class is used to create a push buttons.
• A toggle button is two states button that allows user to switch on and off. To create a toggle button in Swing we
use JToggleButton class
• The JTextField component allows us to enter/edit a single line of text.
• The JTextArea is used to accept several lines of text from the user and it has capabilities not found in the AWT
class.
• Swing provides a combo box (a combination of a text field and a dropdown list) through the JComboBox class,
which extends JComponent. A combobox normally displays one entry.
• A dialog is defined as a conversation between two or more persons. In a computer application a dialog is a
window which is used to "talk" to the application.
• Message dialogs are simple dialogs that provide information to the user.
• File chooser dialog box is used for navigating the file system.
• The class JColorChooser provides a pane of controls designed to allow a user to manipulate and select a color.
EVENT HANDLING :
Mr

• Changing the state of an object is known as an even.


• The java.awt.event package provides many event classes and Listener interfaces for event handling.
• Each event must return a Boolean value (true or false).
•An Event is an object that describes a state change in a source.
.R

•Event handling is a process of responding to events that can occur at any time during execution of a
program.
ADAPTERS :
• Adapter pattern is frequently used in modern Java frameworks.
• Adapter pattern works as a bridge between two incompatible interfaces.
oh

• This pattern involves a single class which is responsible to join functionalities.


ANONYMOUS INNER CLASSES :
• Anonymous classes of Java are called anonymous because they have no name.
• A class that have no name is known as anonymous inner class in Java.
it

•An anonymous class is a local class without a name.

You might also like