I
want to share how to BORDER 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 java.awt.BorderLayout;
import java.awt.LayoutManager;
import javax.swing.JButton;
import javax.swing.JFrame;
public class Main {
private static LayoutManager Layout;
// public Main() {
//}
public static void main(String[] args) {
JFrame frame =new JFrame("BorderLayout");
BorderLayout layout=new BorderLayout(1,1);
frame.getContentPane().setLayout(layout);
JButton btnNorth = new JButton("North Position");
JButton btnSouth = new JButton("South Position");
JButton btnEast = new JButton("East Position");
JButton btnWest = new JButton("West Position");
JButton btnCenter = new JButton("Center Position");
frame.getContentPane().add(btnNorth,BorderLayout.NORTH);
frame.getContentPane().add(btnSouth,BorderLayout.SOUTH);
frame.getContentPane().add(btnEast,BorderLayout.EAST);
frame.getContentPane().add(btnWest,BorderLayout.WEST);
frame.getContentPane().add(btnCenter,BorderLayout.CENTER);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.show();
}
}
0 komentar:
Posting Komentar