import java.awt.BorderLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
public class ShowBorderLayout extends JFrame {
public ShowBorderLayout()
{
setLayout(new BorderLayout(5, 5));
add(new JButton("East"), BorderLayout.EAST);
add(new JButton("South"), BorderLayout.SOUTH);
add(new JButton("West"), BorderLayout.WEST);
add(new JButton("North"), BorderLayout.NORTH);
add(new JButton("Center"), BorderLayout.CENTER);
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
ShowBorderLayout frame = new ShowBorderLayout();
frame.setTitle("ShowBorderLayout");
frame.setSize(300, 200);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
JAVA学习--BorderLayout
最新推荐文章于 2021-08-21 16:47:22 发布