import javax.swing.*;
public class test {
JFrame f = new JFrame("测试");
Box top = new Box.createVerticalBox();
public static void main(String[] args)
{

}
}
为什么Box后面的创建方法调用不起来,老显示有错误呀??

解决方案 »

  1.   


    如果无参的构造函数应该这样用,如果是别的,请输入 入参 
    Box top = new Box().createVerticalBox(); 
      

  2.   

    我看大部分是这样  呵呵 Box top =   Box.createVerticalBox(); 
      

  3.   

    需要先new完,再top.createVerticalBox()吧
      

  4.   

    import javax.swing.Box;
    import javax.swing.JFrame;
    class test { 
    JFrame f = new JFrame("测试"); 
    Box top =Box.createVerticalBox(); 
    public static void main(String[] args) 
    { } 
      

  5.   

    Box top = new Box.createVerticalBox(); 
    这是什么写法啊
    正常写法createVerticalBox这个方法是一个静态方法
    Box top = Box.createVerticalBox();