I
want to share how to BOX LAYOUT 2 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 javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
public class Main {
// public Main() {
//}
public static void main(String[] args) {
JFrame frame =new JFrame("BoxLayout");
Box comp = new Box(BoxLayout.Y_AXIS);
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");
comp.add(btn1);
comp.add(btn2);
comp.add(btn3);
comp.add(btn4);
comp.add(btn5);
frame.getContentPane().add(comp);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.show();
}
}
0 komentar:
Posting Komentar