Graphical User Interface (GUI) on Object-Oriented Programming with Java

Thebestindonesia.com – GUI stands for Graphical User Interface. GUI is an interface device that allows users to interact with electronic devices.

Inside the GUI are several elements, such as icons, menus, widgets, and tabs. To use these elements, the GUI will usually get input or input manually either by typing physically or via a touch screen or touchscreen.

In its development, the GUI is continuously being developed to provide convenience to its users further. Some of these developments, for example, are remote and gesture technology which will become an input method in the future.

Why do we need GUI?

Maybe you ask why the GUI is needed. Do computers need a GUI? To answer this, we need to divide it into two answers. The first answer for ordinary people, then, is that the GUI is required. GUI is a tool that can simplify a function, as you can see now that computers or laptops are straightforward to use. This cannot be separated from the role of the GUI.

In Java GUI, this will use one of the libraries, Swing. Swing is a widget toolkit for Java that is part of Sun Microsystems’ Java Foundation Classes (JFC) and is an API (Application Programming Interface) that provides a Graphical User Interface (GUI). Swing is the latest library and GUI component (javax.swing) from Java and is recommended by Sun Microsystems for GUI programming. Swing was developed as a provider of more advanced GUI components than the previous ones. Swing components are primarily derivatives of the Abstract Window Toolkit (AWT) and are more complete than AWT.

Read also : Exception on Object-Oriented Programming with Java and Its Implementation

Here are some of the essential components of Swing, including:

  1. Top-Level Containers. The base container where the other components are placed (JFrame, JDialog, and Applet).
  2. Intermediate Containers. Different components are placed in the intermediate container (JPanel, JScrollPane, JTabbedPane, JToolbar, JSplitPane).
  3. Atomic Components. Components with specific functions receive direct interaction from the user (JButton, JLabel, JTextArea, and so on).
  4. Layout Manager. Sets the layout and position of components in containers (BorderLayout, BoxLayout, FlowLayout, GridBagLayout, GridLayout).
  5. Event Handling. Handling user events (mouse clicks, keyboard typing, zoom-in frame, and so on).

Event Handling is necessary for an object to be notified about an event. The thing must register itself as an event listener to the source that generated the event and implement the appropriate listener interface. Events are events or events that are carried out by the user on the user interface using the mouse and keyboard equipment. Each object can be notified if an event occurs so that object can decide what to do to respond to (handle) the event, which can be called event handling. The process of handling this incident, among others:

  1. The component must be registered as a listener using the addXXXListener() method.
  2. Implementing the listener interface or extending the adapter class (you can also create an inner class)
    Write the code in the event handler in the method handler.

Tinggalkan Balasan

Alamat email Anda tidak akan dipublikasikan. Ruas yang wajib ditandai *