Java界面布局一般步骤

来源:互联网 发布:ubuntu mysql自启动 编辑:程序博客网 时间:2024/04/30 04:51

1.new一个对象出来   如: Frame fm=new Frame()    ,Panel  pn=new Panel();


2. 设置背景色    fm.setBackground(Color.pink);


3. 设置大小和位置  fm.setBounds(45,45,400,300);//注:  fm.setLocation(45,45);加fm.setSize(400,300)也能达到同样效果


4. 设置布局  fm.setLayout(null);//取消默认布局. 


5.setResizable(true);//是否可以鼠标拖拉窗口尺寸


6.讲组件添加到Frame中 fm.add(pn);


7.设置可见 fm.setVisible(true);



0 0
原创粉丝点击