B
Bernd1983
Gast
hi so ich versuchs jetzt stückenweise ein Programm zu lösen:
ich soll ein Rechteck zeichnen mit Mousclicks und maus ziehen. mein Rechteck verfügt zurzeit über vier Variablen: Konstruktor new Quad(x,y,width,heigth);Genaue Angabe:
Painting shall be possible through dragging the mouse. The first click defines the start position:
code in einer swing Klasse:
ok kein Problem
then while holding the mouse button and moving the mouse the extent of the figure is set.
und von Klasse MouseMotionListener
pubic void mouseDragged(MouseEvent me){ }[/code]
ok wie realisiere ich nun diese zwei Methoden lt. Angabe? Bitte um Tipps
ich soll ein Rechteck zeichnen mit Mousclicks und maus ziehen. mein Rechteck verfügt zurzeit über vier Variablen: Konstruktor new Quad(x,y,width,heigth);Genaue Angabe:
Painting shall be possible through dragging the mouse. The first click defines the start position:
code in einer swing Klasse:
ok kein Problem
Code:
class MyMouseListener implements MouseListener
{
public void mouseClicked(MouseEvent me) {};
public void mousePressed(MouseEvent me) {
Point po=me.getPoint();
x=po.x;
y=po.y;
}
then while holding the mouse button and moving the mouse the extent of the figure is set.
Code:
public void mouseReleased(MouseEvent me){
}
und von Klasse MouseMotionListener
pubic void mouseDragged(MouseEvent me){ }[/code]
ok wie realisiere ich nun diese zwei Methoden lt. Angabe? Bitte um Tipps