Tips for heathy life

Tips for heathy life

Kamis, 30 Oktober 2008

FLOW LAYOUT CENTER in J2SE



I want to share how to FLOW LAYOUT CENTER in J2SE. You can use this code but if you copy this code and paste in your blog/website, please insert this link of article.

import java.awt.FlowLayout;
import javax.swing.JButton;
import javax.swing.JFrame;

public class Main {


// public Main() {
//}

public static void main(String[] args) {
JFrame frame =new JFrame("FlowLayout CENTER");
FlowLayout layout= new FlowLayout(FlowLayout.CENTER);

layout.setVgap(10);
layout.setHgap(10);

frame.getContentPane().setLayout(layout);
JButton btn1 = new JButton("Position 1");
JButton btn2 = new JButton("Position 2");
JButton btn3= new JButton("Position 3");
JButton btn4 = new JButton("Position 4");
JButton btn5 = new JButton("Position 5");

frame.getContentPane().add(btn1);
frame.getContentPane().add(btn2);
frame.getContentPane().add(btn3);
frame.getContentPane().add(btn4);
frame.getContentPane().add(btn5);

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(380,110);
frame.show();
}
}

0 komentar:

Posting Komentar