テキストでJFrameをセットアップしようとしていますが、問題があります。私はJFrameを作成することはできますが、背景色やテキストを操作することはできません。JFrameの作成とテキストの追加に問題があります
import java.awt.Color;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
class FundManager {
JFrame window;
JPanel panel;
JLabel text;
public void createWindow()
{
//Create the window
window = new JFrame();
window.setVisible(true);
window.setSize(960, 540);
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.setLocationRelativeTo(null);
//Create the panel
panel = new JPanel();
panel.setBackground(Color.RED);
//Create the label
text = new JLabel("test");
}
public static void main(String args[]) {
FundManager.createWindow();
}
}
私createWindow()
方法が実行されていないと私はエラーを取得する:
cannot make a static reference to to the non-static method.
しかし、私はそれがプログラム全体の休憩を静的作るとき。