全国免费服务热线:

18982081108
✕

成都网站维护公司,网站安全维护,网站SEO优化,网站内容运营

使用JavaFx创建可拖动的Applet示例

JavaFx运行时的下载地址:
http://javafx.com/downloads/all.jsp

我的appspot地址,打开即可看到示例:
http://sonicluo3.appspot.com/

JavaFx的主方法 MyJavaFXStage.fx
Java代码

 
 
 
  1. package org.webbiscuit;   
  2.   
  3. import javafx.scene.*;   
  4. import javafx.scene.image.*;   
  5. import javafx.stage.*;   
  6. import javafx.scene.text.*;   
  7. /**  
  8.  * @author sonic  
  9.  */  
  10.   
  11. Stage {   
  12.     title: "Application title"  
  13.     width: 300  
  14.     height: 280  
  15.     scene: Scene {   
  16.         content:[   
  17.          Text {   
  18.             font : Font {   
  19.                 size : 16  
  20.             }   
  21.             x: 10, y: 200  
  22.             content: "Hello,这是一个 JavaFx + 可拖动Applet\n+ GAE 的应用! It's very cool!!"  
  23.         },   
  24.             ImageView { image: Image { url: "{__DIR__}GAE_java.png"  }  }   
  25.         ]   
  26.     }   
  27. }  
  28. package org.webbiscuit;
  29. import javafx.scene.*;
  30. import javafx.scene.image.*;
  31. import javafx.stage.*;
  32. import javafx.scene.text.*;
  33. /**
  34.  * @author sonic
  35.  */
  36. Stage {
  37.     title: "Application title"
  38.     width: 300
  39.     height: 280
  40.     scene: Scene {
  41.         content:[
  42.          Text {
  43.             font : Font {
  44.                 size : 16
  45.             }
  46.             x: 10, y: 200
  47.             content: "Hello,这是一个 JavaFx + 可拖动Applet\n+ GAE 的应用! It's very cool!!"
  48.         },
  49.             ImageView { image: Image { url: "{__DIR__}GAE_java.png"  }  }
  50.         ]
  51.     }
  52. }

部署的html文件如下,内嵌了JavaFx的Applet.
Html代码

 
 
 
  1. <html>  
  2. <head>  
  3. <meta http-equiv="Content-Type" content="text/html; charset=gb2312">  
  4. <title>JavaFXApplet</title>  
  5. </head>  
  6. <body>  
  7. <h2>按住 Alt 键,然后拖动鼠标就可以把Applet拉到桌面了.</h2>  
  8. <script src="http://dl.javafx.com/1.1/dtfx.js"></script>  
  9. <script>  
  10.     javafx(   
  11.         {   
  12.               archive: "JavaFXApplet.jar",   
  13.               draggable: true,   
  14.               width: 300,   
  15.               height: 280,   
  16.               code: "org.webbiscuit.MyJavaFXStage",   
  17.               name: "JavaFXApplet"   
  18.         }   
  19.     );   
  20. </script>  
  21. </body>  
  22. </html>  
  23. <html>
  24. <head>
  25. <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
  26. <title>JavaFXApplet</title>
  27. </head>
  28. <body>
  29. <h2>按住 Alt 键,然后拖动鼠标就可以把Applet拉到桌面了.</h2>
  30. <script src="http://dl.javafx.com/1.1/dtfx.js"></script>
  31. <script>
  32.     javafx(
  33.         {
  34.               archive: "JavaFXApplet.jar",
  35.               draggable: true,
  36.               width: 300,
  37.               height: 280,
  38.               code: "org.webbiscuit.MyJavaFXStage",
  39.               name: "JavaFXApplet"
  40.         }
  41.     );
  42. </script>
  43. </body>
  44. </html>

//令做可拖动的纯粹的Applet还有另外一种方式的,找个时间整理了再发上来