

The JWindow class uses ‘BorderLayout’ as the default layout. JWindow: The JWindow class of Swing inherits the Window class directly.Some of the important classes of Swing API are as follows: Some of the classes that inherit from JComponent are JLabel, JList, JTextBox, etc. There are also Component classes derived from the JComponent class of Swing API. In Java, Containers are divided into two types as shown below:Ī Swing API hierarchy in Java is shown below:Īs seen from the above hierarchy we have Container classes – frame, dialog, Panel, Applet, etc. A container provides a space in which we can display components and also manage their spacing, layout, etc. One or more components form a group and this group can be placed in a “Container”. It has got a specific functionality and is represented as an individual class in Swing API.įor example, class JButton in swing API is a button component and provides the functionality of a button. Swing has a big set of components that we can include in our programs and avail the rich functionalities using which we can develop highly customized and efficient GUI applications.Ī component can be defined as a control that can be represented visually and is usually independent. We can simply change the values and thus alter the look-and-feel at runtime.This is because the appearance or look-and-feel of the component is independent of internal representation and hence we can customize it in the way we desire. The swing controls are highly customizable.Swing API provides a set of advanced controls like TabbedPane, Tree, Colorpicker, table controls, etc.
#Flowlayout space between components code
The swing components are written in pure Java and also components are rendered using Java code instead of underlying system calls.

The swing component’s data is represented using Model.The main characteristics of this architecture are: Swing API in Java adapts MVC (Model View Controller) Architecture. Also, Swing has various advanced component tabbed panes. So swing in a way acts as a replacement of AWT. In general, the Swing API has every control defined in javax.swing package that is present in AWT. So in a javax.swing package, we will have classes like JButton, JFrame, JTextField, JTextArea, etc. The classes in the javax.swing package begins with the letter ‘J’. The Swing framework in Java is provided through the ‘javax.swing’ package. The Swing framework is written entirely in Java. But unlike AWT, the Swing components are light-weight and are platform-independent. The Swing framework in Java is built on top of the AWT framework and can be used to create GUI applications just like AWT. JFC is an API that is similar to MFCs (Microsoft Foundation Classes) in C++. The Swing framework in Java is a part of Java Foundation Classes or commonly called JFCs. In this tutorial, we will discuss yet another GUI framework in Java i.e. Another disadvantage of AWT is its heavyweight components. AWT is one of the oldest GUI frameworks in Java and is also platform dependent. We have seen one in our previous tutorial i.e. Java provides many GUI frameworks that help us in developing a variety of GUI applications.
