Java Swing GUI Components Overview
Java Swing GUI Components Overview
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.
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:
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.