mardi 5 juin 2007

2 petits scripts JavaFX Script

Le premier fait tourner un bouton sur lui-même lorsque l’on appuie dessus et le second montre comment changer le look & feel d’une frame JavaFX Script Script 1
import javafx.ui.*;
import javafx.ui.canvas.*;
import java.lang.System;

class AnimationExample {
  attribute rotationValue: Number;
}

var animationExample = new AnimationExample();

var f = Frame {
     title: "Animation - Rotate Button JavaFX Script"
     width: 800
     height: 600    
     content:
Canvas {
  content:
  [
  View {
      transform: bind [ translate(350, 54),
            rotate(animationExample.rotationValue, 40,11) ]
      size: {width: 80, height: 22}
      content: Button {
          text: "Rotate"
          font: new Font("Arial", "PLAIN", 11)
          action: operation() {
              animationExample.rotationValue = [1..360] dur 1000 linear;
          }
      }
  }
  ]
}
  visible: true
};
Script 2
import javafx.ui.*;
import javafx.ui.canvas.*;
import java.lang.System;

import javax.swing.SwingUtilities;
import javax.swing.UIManager;

var f = Frame {
     title: "Change Look & Feel JavaFX Scrit"
     width: 800
     height: 600
     content:

Canvas {
  content:
  [
  View {
      transform: bind [ translate(350, 54), ]
      size: {width: 80, height: 22}
      content: Button {
          text: "Button"
          font: new Font("Arial", "PLAIN", 11)
          action: operation() {
          println("Operation");
          }
      }
  },
  View {
          transform: bind [ translate(350, 84) ]
          size: {width: 80, height: 22}
          content: TextField {
          font: new Font("Arial", "PLAIN", 11)
          }
      }
      ]
  }

  visible: true
};
//f.pack();

UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
//UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");

SwingUtilities.updateComponentTreeUI(f.frame);


Aucun commentaire: