Hey!
ich will eine Canvas erstellen und hab dazu folgende Subklasse geschrieben:
class Canvas extends java.awt.Canvas
{
private JFrame frame;
private CanvasPane canvas;
private Graphics2D graphic;
private Color backgroundColour;
private Image canvasImage;
public Canvas()
{
super();
}
public void drawLine(int x1, int y1, int x2, int y2)
{
graphic.drawLine(x1, y1, x2, y2);
canvas.repaint();
}
public void drawString(String text, int x, int y)
{
graphic.drawString(text, x, y);
canvas.repaint();
}
public void setForegroundColour(Color newColour)
{
graphic.setColor(newColour);
}
private class CanvasPane extends JPanel
{
public void paint(Graphics g)
{
g.drawImage(canvasImage, 0, 0, null);
}
}
}
was ist daran falsch??