メソッドGetContentPane()は型studyで未定義ですと出ます。
どこがおかしいかわかりますか?
package study;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.LinearGradientPaint;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.Container;
import java.awt.BorderLayout;
public class Study{
public static void main(String[] args) {
GameWindow gw = new GameWindow("テストプログラム",400,300);
gw.add(new Draw());
gw.setVisible(true);
JPanel Draw = new JPanel();
JButton button1 = new JButton("OK");
Draw.add(button1);
Coo co = new Coo();
Container contentPane = getContentPane();
contentPane.add(Draw, BorderLayout.CENTER);
}
}
class Coo {
}
//ウィンドウクラス
class GameWindow extends JFrame{
public GameWindow(String title, int width, int height) {
super(title);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setSize(width,height);
setLocationRelativeTo(null);
setResizable(true);
}
}
class Draw extends JPanel{
Draw(){
}
LinearGradientPaint p = new LinearGradientPaint(
0
, 0
, 300
, 200
, new float[] {
0.0f
, 0.5f
, 1.0f
}
, new Color[] {
new Color(255, 0, 0)
, new Color(0, 255, 0, 100)
, Color.BLUE
}
);
public void paintComponent(Graphics g){
super.paintComponent(g);
Graphics2D g2 = (Graphics2D)g; g2.setPaint(p); g.fillOval(0, 0, 300, 200); }
}