我有一个非常基本的应用程序,我认为应该改变一个图像的宽度,但它什么也不做.有人能告诉我为什么,当我点击图像时,图像不会发生任何变化吗?
(注意,图像本身并不重要,我只是想弄清楚如何在JavaFX中缩小、增长和图像)
import javafx.application.Frame;
import javafx.application.Stage;
import javafx.scene.image.ImageView;
import javafx.scene.image.Image;
import javafx.input.MouseEvent;
var w:Number = 250;
Frame {
title: "Image View Sample"
width: 500
height: 500
closeAction: function() {
java.lang.System.exit( 0 );
}
visible: true
stage: Stage {
content: [
ImageView {
x: 200;
y: 200;
image: Image {
url: "{__DIR__}/c1.png"
width: bind w;
}
onMouseClicked: function( e: MouseEvent ):Void {
w = 100;
}
}
]
}
}谢谢大堆!
发布于 2008-11-12 22:58:54
尝试绑定缩放属性:
import java.lang.System;
import javafx.application.Frame;
import javafx.application.Stage;
import javafx.scene.image.ImageView;
import javafx.scene.image.Image;
import javafx.input.MouseEvent;
var w:Number = 1;
Frame {
title: "Image View Sample"
width: 500
height: 500
closeAction: function() {
java.lang.System.exit( 0 );
}
visible: true
stage: Stage {
content: [
ImageView {
x: 200
y: 200
anchorX:200
anchorY:200
scaleX:bind w
scaleY:bind w
image: Image {
url: "{__DIR__}/time.png"
}
onMouseClicked: function( e: MouseEvent ):Void {
w += 0.1;
}
}
]
}
}发布于 2008-11-20 09:32:39
谢谢您的回复,很抱歉耽误了您的时间,但是事实证明,您所需要做的就是绑定映像本身:
image: bind Image {
url: "{__DIR__}/time.png"
width: w;
}这似乎能起作用,我个人觉得有点不正确,但是,它起作用了
https://stackoverflow.com/questions/279583
复制相似问题