[JavaFX] 编写官方例子,语法报错问题?(http://developers.sun.com.cn/javafx/1/tutorials/ui/events/index.)
sping031
2009-12-07
package test; import javafx.scene.Scene; import javafx.stage.Stage; import javafx.scene.Group; import javafx.scene.image.Image; import javafx.scene.image.ImageView; import javafx.scene.paint.Color; import javafx.scene.text.Font; import javafx.scene.text.Text; import javafx.animation.Timeline; def playNormal =Image{ url:"{__DIR__}play_onMouseExited.png"; }; def playPressed =Image{ url:"{__DIR__}play_onMousePressed.png"; }; def stopNormal =Image{ url:"{__DIR__}stop_onMouseExited.png"; }; def stopPressed=Image{ url:"{__DIR__}stop_onMousePressed.png"; }; def playHover = Image { url: "{__DIR__}play_onMouseEntered.png" }; def stopHover = Image { url: "{__DIR__}stop_onMouseEntered.png" }; var mode = true; var image = playNormal; def appear1 = Timeline { keyFrames: [ at(0s) {tooltip.opacity => 0.0}, at(0.5s) {tooltip.opacity => 1.0} ] }; var button = ImageView { var X : Number; var Y : Number; image: bind image; onMousePressed:function(event){ X = event.sceneX - event.node.translateX; Y = event.sceneY - event.node.translateY; image = if(mode){ playPressed; }else{ stopPressed; } }; onMouseReleased: function(event) { if (mode){ //image = stopNormal; image = stopHover; mode = false; } else { image = playNormal; image = playHover; mode = true; } }; onMouseDragged: function(event) { if (event.sceneX - X <0) { event.node.translateX = 0; } else { if (event.sceneX - X > 300 - image.width){ event.node.translateX = 300 - image.width; } else { event.node.translateX = event.sceneX - X; } } if (event.sceneY - Y <0) { event.node.translateY = 0; } else { if (event.sceneY - Y > 240 - image.height){ event.node.translateY = 240 - image.height; } else{ event.node.translateY = event.sceneY - Y; } } }; onMouseEntered: function(event) { image = if (mode){ playHover; } else { stopHover } appear1.rate = 1; appear1.play(); }; onMouseExited: function(event) { image = if (mode){ playNormal; } else { stopNormal } appear1.rate = -1; appear1.play(); } }; var tooltip = Text { content: bind if (mode) "Play Button" else "Stop Button"; translateX: bind button.translateX; translateY: bind button.translateY + 80 ; opacity: 0.0; font: Font { size: 12; name: "Tahoma"; } fill: Color.BLACK; }; Stage{ scene:Scene{ width:300; height:240; content: Group{ content:[ button, tooltip ] } } } |
|
chenweionline
2009-12-07
def appear1 = Timeline {
keyFrames: [ at(0s) {tooltip.opacity => 0.0}, at(0.5s) {tooltip.opacity => 1.0} ] }; 改成 def appear1 : Timeline = Timeline { keyFrames: [ at(0s) {tooltip.opacity => 0.0}, at(0.5s) {tooltip.opacity => 1.0} ] }; |
|
sping031
2009-12-07
谢谢。。能留下你的QQ吗?我公司正在用JAVAFX开发项目,以后能互相指教!
|
相关讨论
相关资源推荐
- 【W: GPG error: https://developer.do....E: The repository ‘https://develope】
- 微信小程序将域名设置到后台的步骤(报错信息: https://api.zbztb.cn 不在以下 request 合法域名列表中,请参考文档:https://developers.weixin.qq.
- 解决报错:GET https://cdn.jsdelivr.net/npm/vant@3/lib/index.css net::ERR_NAME_NOT_RESOLVED
- 不在以下 request 合法域名列表中,请参考文档:https://developers.weixin.qq.com/miniprogram/dev/framework/ability/networ
- 关于https://developer.android.com/国内无法访问解决办法
- github使用错误fatal: Cannot get https://gerrit.googlesource.com/git-repo/clone.bundle问题解决办法
- Invalid content was found starting with element ‘{“http://maven.apache.org/POM/4.0.0“:plugin}‘. One
- Invalid content was found starting with element ‘{“http://maven.apache.org/POM/4.0.0“:dependency}‘.
- JFinal 报错 init datasource error, url: jdbc:mysql://localhost........
- 不在以下合法域名列表中,请参考文档:https://mp.weixin.qq.com/debug/wxadoc/dev/api/network-request.html