解决方案 »

  1.   

    this. getContentPane 把
    不然怎么编译怎么找到
      

  2.   

    试过了,不行,他是继承类,我把整个程序都贴出来吧
    package test;
    import javax.swing.*;
    import java.awt.*;class FrameTest
    {
         JFrame frameObj; 
         public FrameTest()
        {
          frameObj=new JFrame("window");
          frameObj.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          frameObj.setVisible(true);
          frameObj.setSize(600,400);
    }
    }
    class ButtonTest extends FrameTest
    {
          JButton buttonObj1;
          JButton buttonObj2;
          JButton buttonObj3;
          JButton buttonObj4;
          public ButtonTest()
          {
           buttonObj1=new JButton("播放");
           buttonObj2=new JButton("上一首");
           buttonObj3=new JButton("下一首");
           buttonObj4=new JButton("暂停");
           getContentPane().add("West",buttonObj1);
           getContentPane().add(buttonObj2);
           getContentPane().add(buttonObj3);
           getContentPane().add(buttonObj4);
          }
    }
    class FlowLayoutTest extends ButtonTest
    {
          FlowLayoutTest layoutObj;
          public FlowLayoutTest()
          {
           layoutObj=new FlowLayoutTest();
           getContentPane().setLayout(layoutObj);
          }
    }
    public class J1_Frame
    {
    public static void main(String[] args)
    {
    new FlowLayoutTest();
    }
    }
      

  3.   

    好吧 你看的什么书啊 getContentPane这个东西是谁的呢?呵呵
    你看你代码 你那个对象有 getContentPane了 
    是jframe?class FrameTest
    {
         JFrame frameObj; 
         public FrameTest()
        {
          frameObj=new JFrame("window");
          frameObj.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          frameObj.setVisible(true);
          frameObj.setSize(600,400);
    }
       public ???   getContentPane(){  //这里的??? 你自己写一下返回类型
              return this.frameObj.getContentPane();
       }
    }另外1合理情况应该FrameTest 继承JFrame
    另外JFrame是不是可以直接 add 控件了
    你要看看api
      

  4.   

    我在FrameTest中继承了一下JFrame就解决问题了