2. What is Java Swing?
Java Swing is a part of Java Foundation Classes
(JFC) that is used to create window-based
applications. It is also an extension of the
Abstract Window Toolkit [AWT] and entirely
written in java. Java Swing offers much-
improved functionality over AWT, new
components, expanded components features,
and excellent event handling with drag-and-
drop support.
3.
4. AWT (Abstract Windowing Toolkit)
Java AWT (Abstract Window Toolkit) is an API to develop Graphical User
Interface (GUI) or windows-based applications in Java.
Java AWT components are platform-dependent i.e. components are displayed
according to the view of operating system. AWT is heavy weight i.e. its
components are using the resources of underlying operating system (OS).
14. GUI
GUI, which stands for Graphical User
Interface, is a user-friendly visual
experience builder for Java
applications. It comprises graphical
units like buttons, labels, windows, etc.
via which users can connect with an
application. Swing and JavaFX are two
commonly used applications to create
GUIs in Java.
15. API
API stands for application program interface. A
programmer writing an application program can
make a request to the Operating System using API
(using a graphical user interface or command
interface). It is a set of routines, protocols and
tools for building software and applications. It
may be any type of system like a web-based
system, operating system or database System.
16.
17. Container
The Container is a component in AWT that can
contain another components like buttons,
textfields, labels etc. The classes that extends
Container class are known as container such as
Frame, Dialog and Panel.
18. Types of Containers
Window
The window is the container that have no borders and menu bars. You
must use frame, dialog or another window for creating a window. We need
to create an instance of Window class to create this container.
Panel
The Panel is the container that doesn't contain title bar, border or menu
bar. It is generic container for holding the components. It can have other
components like button, text field etc. An instance of Panel class creates
a container, in which we can add components.
Frame
The Frame is the container that contain title bar and border and can have
menu bars. It can have other components like button, text field, scrollbar
etc. Frame is most widely used container while developing an AWT
application.
19. Components
All the elements like the button, text
fields, scroll bars, etc. are called
components. In Java AWT, there are classes
for each component as shown in above
diagram. In order to place every
component in a particular position on a
screen, we need to add them to a
container.
20. Components in Java
Some of the important and common components of the Java Swing class are:
JFrame: JFrame is a top-level container that represents the main window of a
GUI application. It provides a title bar, and minimizes, maximizes, and closes
buttons.
JPanel: JPanel is a container that can hold other components. It is commonly
used to group related components together.
JButton: JButton is a component that represents a clickable button. It is
commonly used to trigger actions in a GUI application.
JLabel: JLabel is a component that displays text or an image. It is commonly
used to provide information or to label other components.
JTextField: JTextField is a component that allows the user to input text. It is
commonly used to get input from the user, such as a name or an address.
21. JCheckBox: JCheckBox is a component that represents a
checkbox. It is commonly used to get a binary input from
the user, such as whether or not to enable a feature.
JList: JList is a component that represents a list of
elements. It is typically used to display a list of options
from which the user can select one or more items.
JTable: JTable is a component that represents a data
table. It is typically used to present data in a tabular
fashion, such as a list of products or a list of orders.
JScrollPane: JScrollPane is a component that provides
scrolling functionality to other components. It is commonly
used to add scrolling to a panel or a table.