0% found this document useful (0 votes)
8 views5 pages

Java Swing GUI Components Overview

Swing is a Java class library for creating graphical user interfaces (GUIs) that includes various components like windows, buttons, and menus. It consists of nine packages containing hundreds of classes and interfaces, with javax.swing.JComponent as the superclass. Key components include JFrame for main windows, JDialog for dialog windows, and JPanel for organizing other components.

Translated by

ScribdTranslations
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)
8 views5 pages

Java Swing GUI Components Overview

Swing is a Java class library for creating graphical user interfaces (GUIs) that includes various components like windows, buttons, and menus. It consists of nine packages containing hundreds of classes and interfaces, with javax.swing.JComponent as the superclass. Key components include JFrame for main windows, JDialog for dialog windows, and JPanel for organizing other components.

Translated by

ScribdTranslations
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

SWING LIBRARY JAVA

Swing is a class library that allows the creation of graphical user interfaces in Java.
(Gallego & Montalvo)A Graphical User Interface (GUI) is a user interface in the
that makes use of a graphical environment. That is to say, it allows user interaction with the
computer through the use of images, pictorial objects (windows, icons,
buttons, etc.), in addition to text... In applications with graphical user interfaces, there
You can make use of a set of graphic elements that allow for better interaction.
of the user with the application.
Elements that a graphical user interface can have
THE WINDOWS
They are elements responsible for housing others and can generally be moved.
freely on the screen, there are different types based on their use and characteristics
COMPONENTS
All those elements of a graphical interface with their own entity and functionality.
associated are components. For example: buttons, scroll bars, labels,
images, drop-down lists, tables, trees, etc. They are not components, for example, the
color, the lines, the letters, the pixels, etc.
Among the components we have:
Controls: these are the components that can receive information from the user.
when it interacts with the application using the mouse or keyboard. The most common ones
buttons, scroll bars, boxes, texts, etc.
Containers: it is a component that can display other components inside it.
Components that are not containers are known as atomic components.
For example, there are containers that show all the components at once, others
containers show some of the components they contain depending on the
active tab, others show the components with scroll bars, etc. To the
Containers are commonly referred to as panels.

MENUS
They are elements that contain buttons arranged vertically.
MENU BARS.
They usually appear at the top of the windows.
TOOLTIP
It is a message that presents the description of a component or simply assistance.
about its usefulness.
Swing is the GUI that Java offers us, consisting of 9 packages that contain hundreds of
classes and interfaces.

The class [Link] is the superclass of the entire class hierarchy of


Swing.

Each of the Swing components is identified because they belong to the package
[Link]. Each Swing application must have at least one top-level container that
will contain the entire application, these can be:

[Link]: An independent window.


[Link]: An applet.
Dialogs: simple interaction windows with the user such as:
[Link]: Dialog window type YES_NO, YES_NO_CANCEL
ACCEPT, etc...
[Link]: Window to choose a file.
[Link]
etc.

A Swing application is built by mixing components with the following rules:


There must be at least one high-level container (TopLevel Container) that provides the
support that the Swing components need for painting and event handling.
Other components hanging from the high-level container (these can be
containers or simple components.
The most important library for Netbeans design work is:
[Link].*; Because it allows the use of controls for the design of the JFrame.
Before the existence of Swing, graphical user interfaces were created through
from AWT (Abstract Window Toolkit), from which Swing inherits all event handling.
Classes and properties:
Containers
Containers are components that allow storing, hosting, or containing others.
graphic elements.
There must exist at least one top-level container (TopLevel Container) that provides the
support that the Swing components need for painting and event handling.
Most important properties
JFrame
This container is one of the main and most used.
represents the main window of our application, in the
we can host other containers.
JDialog
This container represents a window type Window
of dialogue, it can also be a main container,
although it is more recommended given its properties, that
used as a secondary window, that is,
a JFrame as the main window and the rest of the windows
como unJDialog.
JPanel
This container is one of the simplest, it allows for
creation of independent panels where they are stored
other components, this way we decided that
elements are stored in which panels and in case
we can use its properties to hide, move, or delimit sections
JScrollPane
This container allows linking scroll bars or
movement in our application, can be used
both in panels and in other components such as
unJTextArea

JSplitPane
This component allows the creation of a container
divided into 2 sections, often used in
applications where a section shows a list of
properties and another section presents the element to which it
we applied that list
JTabbedPane
This may be one of the most used components.
it allows the creation of tabs in our window,
each tab represents an independent container
where we can store panels or other elements.

JDesktopPane
Este contenedor aloja componentes detpoJInternalFrame,
these represent internal windows, thus allowing the creation of
windows within a main window, at the time of its
creation we can manipulate its properties to define if
we want to resize them, close them, hide them among others

JToolBar
This container represents a Toolbar inside
from our application, in which we can host different
components that we consider useful, buttons, checkboxes, radios,
fields among others

Controls
The JFrame control windows contain a container, and inside this, we must
add a content panel where we will include all the controls we are going to
use. To do this, we will use your method "getContentPane()". That is, before including
Any controls will need to be included within the panel.
In addition to that, we can also include an organization manager called Layout for
the distribution of the controls.
Component
JLabel
Este control, es una simple etqueta donde pondremos texto fijo.
To add a control, in addition to importing its package, we must go through three phases.
First, instantiate the control, second place it in a location, and third add it to the
panel with the method "add()"

JTextField
This control is the one we use as a text field, in which we can input text.
to later use it at our convenience. Now we are going to place in the
window a text field to be able to write in it.
JButton
Este es el control de los famosos botones, con ellos podremos programar las acciones que
we create relevant things for them.

Most important properties

You might also like