public class Exemple1 {
public static void main(String[] args) {
+ // Création de la fenêtre
DrawingWindow w = new DrawingWindow("Exemple 1", 640, 480);
+ // Affichage d'un ensemble de lignes, du centre de la fenêtre
+ // vers les bords
final int cx = w.width / 2;
final int cy = w.height / 2;
final int delta = 5;
public class Exemple2 {
public static void main(String[] args) {
+ // Création de la fenêtre
DrawingWindow w = new DrawingWindow("Exemple 3", 640, 480);
int width = Math.min(w.width - 1, w.height - 1) / 2;
+ // Affichage de rectangles concentriques, avec un dégradé de
+ // couleurs
for (int z = 0; z <= width; z++) {
float r, g, b;
float s = 3.0f * z / width;
g = 0.0f;
b = 1.0f - s;
}
+ // On change la couleur de dessin...
w.setColor(r, g, b);
+ // ... et on affiche un rectangle
w.drawRect(z, z, w.width - 1 - z, w.height - 1 - z);
}
}
static final Random random = new Random();
public static void main(String[] args) {
+ // Création de la fenêtre
DrawingWindow w = new DrawingWindow("Exemple 3", 640, 480);
- for (int i = 0; ; i++) {
-
+ // Sans s'arrêter, affiche des lignes au hasard avec une
+ // couleur tirée aléatoirement
+ while (true) {
int x1 = random.nextInt(w.width);
int y1 = random.nextInt(w.height);
int x2 = random.nextInt(w.width);
public class Hello {
public static void main(String[] args) {
+ // Création d'une fenêtre avec, en paramètres, son titre, sa
+ // largeur et sa hauteur
DrawingWindow w = new DrawingWindow("Exemple 1", 640, 480);
+ // Affichage d'un court message au milieu de la fenêtre
w.drawText(w.width / 2, w.height / 2, "Hello world!");
}
}
-* Add comments to examples
* Add draw/fillTriangle
* Add set(Bg)Color with int
* Add waitMousePress