107,180 views 179 on YTPak
195 65

Published on 24 Jul 2013 | over 3 years ago

Title:how to create dynamically changing jpanels in jframe?

What is Swing?
Swing is a principal GUI toolkit for the Java programming language. It is a part of the JFC (Java Foundation Classes), which is an API for providing a graphical user interface for Java programs. It is completely written in Java (i.e. GUI design and java coding). Java Swing is a lightweight Java graphical user interface (GUI) widget toolkit that includes a rich set of widgets. Swing offers customization of the look and feel of every component in an application without making significant changes to the application code.

Example Program:
import javax.swing.JFrame;
import javax.swing.SwingUtilities;

public class Main {
public static void main(final String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
final JFrame frame = new JFrame();
frame.setSize(600, 400);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
});
}
}

Why we are going for java swing?
1. Swing is light weight Component. Applet is heavy weight Components
2. Swing Using UIManager. Swing have look and feel according to user view u can change look and feel. Applet Does not provide this facility.
3. Swing uses for stand lone Application, Swing have main method to execute the program. Applets need HTML code for Run the Applet.
4. Swing uses MVC Model view Controller. Applet not.
5. Swing have some Thread rules. Applet doent have any rule.

Demo Description:
The demo describes dynamically adding of jpanel in a single jframe in order to increase the coding efficiency rather from designing several jframe. The implementation of grid layout and box layout are done in this demo. The customization of jframe is done by changing the look and feel.

Loading related videos...