我前面用SWING建立了jFrame,又在jFrame中添加了很多jButtion,但是不知道在主函数中写些什么,才能让应用程序显示出图形呢?
由于我是用Jbuilder2007可视编辑直接拉Frame的,本来想用个构件器,直接把所有的内容放里面,但是编译不了.
又试过直接在main函数中使用Frame的setvisible,都是显示不了.还有个问题,JAVA可以在方法中嵌套方法的吗?

解决方案 »

  1.   

    main(){
    JFrame frame=new XXXFrame()
    frame.SetXXXXX;
    ……
    }XXXFrame extends JFrame{
    }
      

  2.   

    主程序?
    main(){
        JFrame   frame=new   XXXFrame()
    frame.add(你想放的东西,都扔进去);
    frame.setVisible(true);// 显示  
    }
      

  3.   

    把你要加的東西都放在構造方法里  在main方法中new一下 就行了 ~~
    public class tableest implements ActionListener{ 
        public tabletest() { 
         
         JFrame jframe = new JFrame(); 
         
            JButton button = new JButton("Test"); 
             
            jframe.setSize(400,400); 
            jframe.add(table); 
            jframe.add(button,BorderLayout.SOUTH); 
            jframe.setLocationRelativeTo(null); 
            jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
            jframe.setVisible(true); 
             
        }   
              
        public static void main(String[] args) { 
            new tabletest(); 

     }
      

  4.   

    public TextName(){
         //在这里放你想要实现的东西
          JButton jbutton=new JButton();
         this.add(jbutton);
         this.seyVisible(true);
    }
    public voic mian(){
        JFrame jframe=new JFrame()//只需要在main方法里面从写一次就可以了   
    }
      

  5.   

    同意4楼的,我用JBuilder2005,那个jFrame不用你在主函数里加的你要做的操作是在另一个没有包括主函数的.java文件中写其他的函数