JavaFX with Passion! Puzzler #1

this is my code to solve the javafx with passion puzzler #1

/*
* NewJavaFXEmpty.fx
*
* Created on 24 Mar 09, 6:59:19
*/

package goobooks;

import javafx.ext.swing.SwingSlider;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.text.Text;
import javafx.scene.text.Font;
import javafx.scene.transform.Rotate;

/**
* @author Hakim
*/

def font = Font{name:”Arial”, size: 40, embolden:true}
def angle = bind slider.value;
var width:Number = 350;
var height:Number = 300;
var pivoty:Number = bind text.boundsInParent.height/2;
var tx = bind (width – text.boundsInLocal.width)/2;
var ty = bind (height – text.boundsInLocal.height)/2;

def slider = SwingSlider {
width: bind width*2/3
translateX: bind width/6
minimum: 0
maximum: 360
value: 0
vertical: false
}

function formatString(num:Integer):String{
if (num < 10) return "Angle: 00{num}" else if (num >= 10 and num < 100) return "Angle: 0{num}" else return "Angle: {num}"; } def text:Text = Text { font: font fill: Color.BLUE translateX: bind tx translateY: bind ty style: "font-weight:bold" rotate: bind angle content: bind formatString(angle) } def scene:Scene = Scene { content: [ slider, text ] } Stage { title: "RotSlider" width: bind width with inverse height: bind height with inverse scene: scene } [/sourcecode]

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s