Flow Layout

//<applet code=FlowLayoutDemo height=500 width=500></applet>
// example of FlowLayout
import java.awt.*;
import javax.swing.*;

public class FlowLayoutDemo extends JApplet {
	JPanel p1;
	JButton b1, b2, b3, b4;
	FlowLayout fl;

	@Override
	public void init() {
		p1 = new JPanel();
		b1 = new JButton("button1");
		b2 = new JButton("button2");
		b3 = new JButton("button3");
		b4 = new JButton("button4");
		// fl=new FlowLayout();
		// fl=new FlowLayout(FlowLayout.RIGHT);
		fl = new FlowLayout(FlowLayout.LEFT, 20, 50);
		p1.setLayout(fl);
		getContentPane().add(p1);
		p1.add(b1);
		p1.add(b2);
		p1.add(b3);
		p1.add(b4);
	}
}

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