1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| bouton_2.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
canvas_2.addPaintListener(new dessin_canvas_2());
canvas_2.redraw();
}
});
...
...
private class dessin_canvas_2 implements PaintListener {
public void paintControl(PaintEvent e) {
GC monGC=e.gc;
Color couleurrouge=new Color(dessins_divers.display, 255,0,0);
int xxx=(int) (Math.random()*165);
int yyy=(int) (Math.random()*165);
monGC.setForeground(couleurrouge);
monGC.drawRectangle(xxx ,yyy ,10,10);
}
}
...
} |
Partager