Button类中有setSize()方法,但好像不能设置Button的大小,请问该用什么方法设置。

解决方案 »

  1.   

    可以吧~ 它继承了java.awt.Component呀~
      

  2.   

    setPreferredSize();用于设置按钮的当前大小,但是得结合Layout使用
      

  3.   

    是你的布局管理的原因吧
    如果上层容器setLayout(null)
    那button的setSize(int,int)肯定有用
      

  4.   

    使用netbeans自动去设吧 !
    呵呵
    那样既方便又快捷
    何乐而不为呢
      

  5.   

    如果Panel.setLayout(null);那么
    Button.setSize(new Dimension(int width, int height))
    Button.setLocation(new Point(int x, int y));
    这样就可以确定一个Button的位置和大小。
    要是用上别的Layout,那就得根据Layout时行自动设置了。