Java SpringLayout Example
Chapter:
Swing
Last Updated:
27-09-2016 18:18:15 UTC
Program:
/* ............... START ............... */
import java.awt.Container;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.SpringLayout;
public class JavaSpringLayoutExample {
public static void main(String[] args) {
JFrame frame = new JFrame("SpringLayout");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container contentPane = frame.getContentPane();
SpringLayout springLayout = new SpringLayout();
contentPane.setLayout(springLayout);
JButton b1 = new JButton("Button 1");
JButton b2 = new JButton("Little Bigger Button 2");
contentPane.add(b1);
contentPane.add(b2);
frame.pack();
frame.setVisible(true);
}
}
/* ............... END ............... */
Notes:
-
An instance of the SpringLayout class in the javax.swing package represents a SpringLayout manager.
- A Spring object has four properties: minimum, preferred, maximum, and current value.
Tags
SpringLayout, Java, Swing