Basic of swing in java

Swing

Swing is a set of component  for Java programmers that provide the ability to create graphical user interface ( GUI ) components. Swing components are Java Foundation Classes ( JFC ) that used to create window-based applications.

Java Foundation Class (JFC)

JFC (Java Foundation Class) represent a class library developed in pure java which is an extension to AWT i.e. JFC is an extension of the original AWT. It contains classes that are completely portable, since the entire JFC is developed in pure java.
Features of JFC as follows,

  • JFC components are light-weight.
  • JFC components have same look and feel on all platforms.
  • JFC offers ‘pluggable look and feel’ feature, which allows the programmer to change look and feel as suited for a platform.
  • JFC offers a rich set of components with lots of features .
  • JFC does not replace AWT. It is an extension of AWT.

Packages of JFC

javax.swing: It is helps to develop component like push buttons, radio buttons, menus, etc. The x represents the ‘extended packages ’ whose classes are derived from the awt packages.
java.swing.plaf: plaf stand for pluggable look and feel.
java.awt.dnd: It is helps to drag and drop the components and data from one place to another in the application.
java.awt.geom: It helps to draw 2D graphics filling with colors, rotating the shapes, etc.

javax.swing and MVC

javax.swing is the most commonly used package among all the other packages of JFC. This package provides classes to create components like push buttons, checkboxes, radio buttons, menus, etc.
All components in swing follows a model-view-controller (MVC) architecture.
Model represents the data of component.
View represent visual appearance of the component based on the model data.
When the user interacts with the components, first of all controller will understand this and modifies the model data accordingly.

Untitled

Important classes of javax.swing

Here, we can understand that the classes of javax.swing are derived from the classes of java.awt package.

 

Untitled

Leave a Reply

Your email address will not be published. Required fields are marked *