グラフィックスとその使い方についてもう少し知りたいです。
私はこのクラスを持っています:
public class Rectangle
{
private int x, y, length, width;
// constructor, getters and setters
public void drawItself(Graphics g)
{
g.drawRect(x, y, length, width);
}
}
そして、このような非常にシンプルなフレーム:
public class LittleFrame extends JFrame
{
Rectangle rec = new Rectangle(30,30,200,100);
public LittleFrame()
{
this.getContentPane().setBackground(Color.LIGHT_GRAY);
this.setSize(600,400);
this.setVisible(true);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
}
public static void main(String[] args)
{
new LittleFrame();
}
}
私がやりたいのは、この長方形をLittleFrameのコンテナに追加することです。しかし、私はそれをどのように行うのか分かりません。