Thursday, August 07, 2008

X檔案: 我不要相信!

前幾天聽說X檔案竟然在十年後又有續集了! 興沖沖的跑去電影院看,一開始Mulder把自己關在房間裡研究飛碟‚Scully好像跟他不是很熟。忽然沒幾分鐘兩個人又睡在一張床上,因為Scully說她害怕睡不著。整片就看兩個人跑過來跑過去。我還沒有弄清楚在演什麼, 忽然螢幕下方捲出演員名單的字幕, 然後我看到鄰座觀眾拿著爆米花離場。啊!原來已經演完了! 錯愕的我呆坐在電影院的椅子上,腦筋一片空白, 真的不知道整片在演什麼, 真是不可思議啊。

Friday, August 01, 2008

It's (almost) official: JavaFX Preview SDK

Sun promised to release JavaFX Preview on July 2008. Yesterday is the last day of July, and they really released it as they promised! Compare to the JavaOne 2008 preview, this release is very impressive. The SDK is bundled with NetBeans 6.1. If you have previous version of JavaFX installed in your NetBeans, you need to remove them first.  I find it easier just to uninstall the NetBeans and let the bundle reinstall from the scratch. On Mac OS X, I simply drag my NetBeans.app into the trash, open Console and rm -r .netbeans* in my home directory.  The installation is simple, and there is no need for other configurations.

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
}
}
]

}
}