Java- Swing Basics

Swing Basics

We can develop standalone applications by using AWT (old) & Swing concepts

For developing any Swing based application we need to extend either java.awt.Frame or javax.swing.JFrame

Difference between AWT and Swing

No. Java AWT Java Swing
1) AWT components are platform-dependent. Java swing components are platform-independent.
2) AWT components are heavyweight. Swing components are lightweight.
3) AWT doesn’t support pluggable look and feel. Swing supports pluggable look and feel.
4) AWT provides less components than Swing. Swing provides more powerful components such as tables, lists, scrollpanes, colorchooser, tabbedpane etc.
5) AWT doesn’t follows MVC Swing follows MVC.
public class FrameDemo extends Frame {
	public FrameDemo() {
 setTitle("Demo");
 setSize(100, 100);
 setBackground(Color.black);
 setForeground(Color.red);
 setVisible(true);
	}

	public static void main(String[] args) {
 new FrameDemo();
	}
}

This is very basic program. We will explain the in detail in upcoming topics