Box容器
来源:互联网 发布:浙江大学网络教育平台 编辑:程序博客网 时间:2024/05/20 20:18
Box容器是天生以BoxLayout为布局管理器的容器,下例展示了它的用法。
(1)Box1.java
//<applet code=Box1 width=450 height=200></applet>
import javax.swing.*;
import java.awt.*;
public class Box1 extends JApplet
{
public void init()
{
Box bv=Box.createVerticalBox();
for(int i=0;i<5;i++)
{
bv.add(new JButton("bv "+i));
}
Box bh=Box.createHorizontalBox();
for(int i=0;i<5;i++)
{
bh.add(new JButton("bh "+i));
}
Container cp=getContentPane();
cp.add(BorderLayout.EAST,bv);
cp.add(BorderLayout.SOUTH,bh);
}
public static void main(String[] args)
{
Console.run(new Box1(),450,200);
}
}
(2)Console.java
import javax.swing.*;
public class Console
{
public static String title(Object o)
{
String t=o.getClass().toString();
if(t.indexOf("class")!=-1)
{
t=t.substring(6);
}
return t;
}
public static void run(JFrame frame,int width,int height)
{
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(width,height);
frame.setVisible(true);
}
public static void run(JApplet applet,int width,int height)
{
JFrame frame=new JFrame(title(applet));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(applet);
frame.setSize(width,height);
applet.init();
applet.start();
frame.setVisible(true);
}
public static void run(JPanel panel,int width,int height)
{
JFrame frame=new JFrame(title(panel));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(panel);
frame.setSize(width,height);
frame.setVisible(true);
}
}
- Box容器
- Box容器中的"支架"概念
- Box容器中的"胶水"概念
- box-sizing:border-box设置并排带边框的容器
- Box容器中的"刚性区域"概念
- Flex拖拽-Canvas容器里拖动Box
- Swing —— Box容器组件
- PyGobject(四十一)布局容器之Box
- MP4容器系列文章之STSD BOX
- 软编码Flv 到Mp4 容器(五) fmp4 ftyp box 和moov>mvhd box详解
- [疯狂Java笔记]AWT:BoxLayout盒式布局、Box容器
- GTKmm 練習筆記(一)關於BOX容器的應用
- 软编码Flv 到Mp4 容器(外传一)avcc box
- box
- Box
- box
- Box
- Box
- 人生思考,如何高薪
- iwebAx产品家族之iweb SuperInteraction
- C#操作XML小结
- (转载)怎样提高解决问题的能力
- BoxLayout布局管理器
- Box容器
- 今天的日子太特殊了
- 与的区别
- iwebAx产品家族之iweb SNS v0.6体验版--不错的开源软件~~
- Box容器中的"支架"概念
- (转载)使用RSS的好处
- Box容器中的"胶水"概念
- Linux服务器网络开发模型
- (转载,非常不错的)基于互联网信息收集的技巧