我无法制作ContentPane
静态,但我必须访问它在我在另一个类中访问的另一种方法中,我不断收到此错误:
Cannot make a static reference to the non-static method
getContentPane() from the type JFrame
..当我尝试setSize
Cannot make a static reference to the non-static method setDefaultCloseOperation(int) from the type JFrame
我感到很困惑。你能帮我么?
编辑1
ToutrialStart
public class ToutrialStart extends JFrame implements ActionListener
{
static Container contentPane = getContentPane();
public static void schoolDecider()
{
contentPane.setLayout(null);
contentPane.setBackground(Color.BLACK);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setSize(1024, 600);
setLocation(0,0);
setTitle("Title");
setResizable(false);
}
}
touDia
public class touDia extends JFrame implements actionListener
{
public void school()
{
ToutrialStart.schoolDecider();
}
}