读书人

新手提问:小弟我的setsize()函数如何

发布时间: 2011-12-31 23:50:30 作者: rapoo

新手提问:我的setsize()函数怎么不管用?
shell.setSize(200,400);
shell.setBounds(600,300,0,0);

setSize怎么改数字都没有反应
setBounds可以用的~!!


[解决办法]
你不要shell.setSize(200,400);后再用
shell.setBounds(600,300,0,0);这样不就重复了么
[解决办法]
setBounds后面的两个参数的作用就是setSize
[解决办法]
public void setBounds(int x,
int y,
int width,
int height)
/*x - the new x-coordinate of this component
y - the new y-coordinate of this component
width - the new width of this component
height - the new height of this component*/
按照这样使用,没有效果,也不报错。可能和布局方式有关?
[解决办法]
shell.layout();
[解决办法]
是否是shell.pack();的原因,

将setsize()后的shell.pack()去掉
[解决办法]
你自己是正确的,以后提问贴出代码要全面一点,呵呵
[解决办法]
楼上说的就是啊!!!
你是不是别的地方有问题啊

读书人网 >Eclipse开发

热点推荐