1.看lz的需求应该适合GridBagLayout.把Button的大小固定,让TextField自适应宽度.
2.fr.setResizable(false);既然不可变,也可以用XYLayout.
2.fr.setResizable(false);既然不可变,也可以用XYLayout.
解决方案 »
- java用weboffice在action怎么接传过来的word文档里面的内容?
- 关于拦截器无效的问题
- 高手请进,关于jsp调用嵌套bat命令
- Struts2登录出现404错误,帮个忙
- ejb3.0在JBoss中部署的问题
- 赛尔凯达到底怎么样?
- hibernate JDBCException logWarnings SQL Warning: 17110, SQLState: null
- 如何将hql显示到控制台
- 关于axis开发web服务实例的问题,请教各位! ! !
- 在java中使用mencoder将rmvb格式视频转换成avi格式视频后为0字节
- jsf可以动态生成组件id吗?
- 帮我看看这个问题:javax.naming.NameNotFoundException: 名称jdbc在上下文中没绑定
import java.awt.event.*; public class dddd
{
public static void main(String args[]){
Frame fr = new Frame("日历记事本");
fr.setSize(650,400);
fr.setLocation(350,200);
fr.setBackground(Color.GRAY);
fr.setResizable(false);//设置窗口大小不可变!!!
fr.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);}
});
fr.setLayout(null);
Panel p1 = new Panel();
Panel p2 = new Panel();
Panel p3 = new Panel();
p3.setBounds(0,20,400,40); //在此做了修改,原来你写的距顶端为0,不过打开的窗口有一段距离
p1.setBounds(0, 60, 400, 340);
p2.setBounds(400, 0, 250, 400);
p3.setBackground(Color.BLUE);
p2.setBackground(Color.cyan);
p3.setLayout(new FlowLayout());
Button b1= new Button("去年");
b1.setBounds(10, 10, 50, 50);
p3.add(b1);
p3.add(new TextField(4));
p3.add(new Button("明年"));
p3.add(new Button("上月"));
p3.add(new TextField(2));
p3.add(new Button("下月"));
fr.add(p3);
fr.add(p1);
fr.add(p2);
fr.setVisible(true);
}
}