I
want to share how to GRID LAYOUT 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.JButton;
import javax.swing.JFrame;
import javax.swing.JTabbedPane;
import javax.swing.JTextArea;
public class Main {
// public Main() {
//}
public static void main(String[] args) {
JFrame frame =new JFrame("GridLayout");
JTextArea text1=new JTextArea("Text 1");
JTextArea text2=new JTextArea("Text 2");
JButton btn1=new JButton("Button 1");
JButton btn2=new JButton("Button 2");
JButton btn3=new JButton("Button 3");
GridLayout layout=new GridLayout(3,2);
layout.setHgap(5);
layout.setVgap(10);
frame.getContentPane().setLayout(layout);
frame.getContentPane().add(btn1);
frame.getContentPane().add(btn2);
frame.getContentPane().add(btn3);
frame.getContentPane().add(text1);
frame.getContentPane().add(text2);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.show();
}
}
0 komentar:
Posting Komentar