静的にすることはできませんが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();
}
}