
The new JavaFX SDK in NetBeans has a lot of enhancement. For people not familiar with the language (that includes almost everyone), the JavaFX Palette provides a quick way to drag-and-drop code snippet into the editor. With the help of the Palette and some online tutorial, I managed to get my first JavaFX test in 20 minutes.

/*
* Main.fx
*
* Created on Aug 1, 2008, 5:19:32 AM
*/
package javafxapplication1;
import javafx.application.Application;
import javafx.application.Stage;
import javafx.application.Frame;
import javafx.ext.swing.ComponentView;
import javafx.ext.swing.Label;
import javafx.scene.geometry.Circle;
import javafx.scene.paint.Color;
import javafx.scene.transform.Rotate;
import javafx.scene.transform.Translate;
import javafx.scene.text.Text;
import javafx.scene.Font;
import javafx.scene.FontStyle;
import javafx.ext.swing.Button;
import javafx.scene.geometry.Rectangle;
import javafx.scene.effect.*;
import javafx.scene.paint.*;
Frame {
title: "MyApplication"
width: 200
height: 200
closeAction: function() {
java.lang.System.exit( 0 );
}
visible: true
stage: Stage {
content: [
ComponentView {
transform: [
Rotate { x : 0.0, y : 10.0, angle: 0.0 },
Translate { x : 5.0, y : 5.0 }
]
component:
Button {
text: "Button"
action: function() {
}
}
},
Rectangle {
x: -40, y: 140
width: 300, height: 90
fill: Color.LIGHTGRAY
transform: [
Rotate { x : 0.0, y : 10.0, angle: -10.0 }
]
},
Circle {
centerX: 100, centerY: 70
radius: 40
fill:
LinearGradient { startX: 0 startY: 0 endX: 1 endY: 1
stops: [
Stop { offset:0 color: Color.web("#ffff00")},
Stop { offset:1 color: Color.web("#5f0101")}
]
}
},
Text {
font: Font {
size: 24
style: FontStyle.PLAIN
}
x: 30, y: 65
content: "Hello JavaFX"
transform: [
Translate { x : 0.0, y : 100.0 }
]
effect: DropShadow {
offsetX: 2 offsetY: 2 radius: 6
color: Color.BLACK
}
}
]
}
}
No comments:
Post a Comment