使用JavaFx創(chuàng)建可拖動的Applet示例
作者:sonicluo3
本文將談?wù)劵贕oogle App Engine,使用JavaFx創(chuàng)建可拖動的Applet示例。JavaFX目前還屬于比較新的一種語言,是Sun在RIA領(lǐng)域的旗桿。
JavaFx運(yùn)行時的下載地址:
http://javafx.com/downloads/all.jsp
我的appspot地址,打開即可看到示例:
http://sonicluo3.appspot.com/
JavaFx的主方法 MyJavaFXStage.fx
Java代碼
- package org.webbiscuit;
- import javafx.scene.*;
- import javafx.scene.image.*;
- import javafx.stage.*;
- import javafx.scene.text.*;
- /**
- * @author sonic
- */
- Stage {
- title: "Application title"
- width: 300
- height: 280
- scene: Scene {
- content:[
- Text {
- font : Font {
- size : 16
- }
- x: 10, y: 200
- content: "Hello,這是一個 JavaFx + 可拖動Applet\n+ GAE 的應(yīng)用! It's very cool!!"
- },
- ImageView { image: Image { url: "{__DIR__}GAE_java.png" } }
- ]
- }
- }
- package org.webbiscuit;
- import javafx.scene.*;
- import javafx.scene.image.*;
- import javafx.stage.*;
- import javafx.scene.text.*;
- /**
- * @author sonic
- */
- Stage {
- title: "Application title"
- width: 300
- height: 280
- scene: Scene {
- content:[
- Text {
- font : Font {
- size : 16
- }
- x: 10, y: 200
- content: "Hello,這是一個 JavaFx + 可拖動Applet\n+ GAE 的應(yīng)用! It's very cool!!"
- },
- ImageView { image: Image { url: "{__DIR__}GAE_java.png" } }
- ]
- }
- }
部署的html文件如下,內(nèi)嵌了JavaFx的Applet.
Html代碼
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
- <title>JavaFXApplet</title>
- </head>
- <body>
- <h2>按住 Alt 鍵,然后拖動鼠標(biāo)就可以把Applet拉到桌面了.</h2>
- <script src="http://dl.javafx.com/1.1/dtfx.js"></script>
- <script>
- javafx(
- {
- archive: "JavaFXApplet.jar",
- draggable: true,
- width: 300,
- height: 280,
- code: "org.webbiscuit.MyJavaFXStage",
- name: "JavaFXApplet"
- }
- );
- </script>
- </body>
- </html>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
- <title>JavaFXApplet</title>
- </head>
- <body>
- <h2>按住 Alt 鍵,然后拖動鼠標(biāo)就可以把Applet拉到桌面了.</h2>
- <script src="http://dl.javafx.com/1.1/dtfx.js"></script>
- <script>
- javafx(
- {
- archive: "JavaFXApplet.jar",
- draggable: true,
- width: 300,
- height: 280,
- code: "org.webbiscuit.MyJavaFXStage",
- name: "JavaFXApplet"
- }
- );
- </script>
- </body>
- </html>
//令做可拖動的純粹的Applet還有另外一種方式的,找個時間整理了再發(fā)上來
【編輯推薦】
責(zé)任編輯:彭凡
來源:
javaeye