BoxDemo.java
资源名称:Java.rar [点击查看]
上传用户:szfcled
上传日期:2022-06-12
资源大小:236k
文件大小:1k
源码类别:
文件格式
开发平台:
Java
- import java.awt.*;
- import javax.swing.*;
- public class BoxDemo {
- private JFrame frame;
- private Box bv,bh;
- public static void main(String args[]) {
- BoxDemo that = new BoxDemo();
- that.go();
- }
- void go() {
- frame = new JFrame("Box Layout example");
- Container contentPane = frame.getContentPane();
- //创建使用垂直方向BoxLayout的Box实例
- bv = Box.createVerticalBox();
- bv.add(new JLabel(" Monday"));
- bv.add(new JLabel(" Tuesday"));
- bv.add(new JLabel(" Wednesday"));
- bv.add(new JLabel(" Thursday"));
- bv.add(new JLabel(" Friday"));
- bv.add(new JLabel(" Saturday"));
- bv.add(new JLabel(" Sunday"));
- contentPane.add(bv, BorderLayout.CENTER);
- //创建使用水平方向BoxLayout的Box实例
- bh = Box.createHorizontalBox();
- bh.add(new JButton("Yes"));
- bh.add(new JButton("No"));
- bh.add(new JButton("Cancel"));
- contentPane.add(bh,BorderLayout.SOUTH);
- frame.pack();
- frame.setVisible(true);
- }
- }