Hallo Leute 
Ich hab hier ein programm welches zeichnen soll
tut es aber nicht was ist falsch?
hier die methode in welcher repaint aufgerufen wird
hier die die zeichnet
und hier der button
bedanke mich auch schon mal im vorraus
Ich hab hier ein programm welches zeichnen soll
tut es aber nicht was ist falsch?
hier die methode in welcher repaint aufgerufen wird
Java:
public void dragged() {
jp.addMouseMotionListener(new MouseMotionListener() {
@Override
public void mouseDragged(MouseEvent e) {
x = e.getX();
y = e.getY();
Random rand = new Random();
System.out.println("x=" + x + ",y=" + y);
String str = "";
xyAusgabe.setText(str);
str = String.format("X: %d Y: %d", x, y);
xyAusgabe.setText(str);
repaint(); //<---------------------REPAINT
}
});
}
hier die die zeichnet
Java:
public void graphicsComponentRect(Graphics graphic) {
Random rand = new Random();
super.paint(graphic);
Graphics g = jp.getGraphics();
if (form == 1) {
if (rainbowOk == 1) {
col = new Color(rand.nextInt(256), rand.nextInt(256), rand.nextInt(256));
g.setColor(col);
} else {
g.setColor(col);
}
g.fillRect(x, y, thick, thick);
}
}
und hier der button
Java:
public void drawRect() {
rect.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent ae) {
form = 1;
}
});
}
bedanke mich auch schon mal im vorraus