ox Layout

//<applet code=BoxLayoutDemo height=500 width=500></applet>
import javax.swing.*;
public class BoxLayoutDemo extends JApplet {
	JPanel p1;

	@Override
	public void init() {
		getContentPane().add(p1 = new JPanel());
		p1.setBounds(30, 30, 300, 300);

		// Create left column of radio buttons
		Box left = Box.createVerticalBox();
		ButtonGroup radioGroup = new ButtonGroup();
		JRadioButton rbutton;
		radioGroup.add(rbutton = new JRadioButton("Red"));
		left.add(rbutton);
		radioGroup.add(rbutton = new JRadioButton("Green"));
		left.add(rbutton);
		radioGroup.add(rbutton = new JRadioButton("Blue"));
		left.add(rbutton);
		radioGroup.add(rbutton = new JRadioButton("Yellow"));
		left.add(rbutton);

		Box right = Box.createVerticalBox();
		right.add(new JCheckBox("A"));
		right.add(new JCheckBox("B"));
		right.add(new JCheckBox("C"));

		Box top = Box.createHorizontalBox();
		// Box top = Box.createVerticalBox();
		top.add(left);
		top.add(right);

		p1.add(top);
	}
}

Download

Layout Manager in Java

Border Layout
Box Layout
Card Layout
Flow Layout
Gridbag Layout
Gridbag Layout
Grid Layout
Design GUI contianer without layout


Write your Comment

Name :
Email Id : [ We will not publish your email id ]
Your Comment : [ Maximum 200 chars ]
Enter Security code