import java.util.Date; import com.sun.javafx.runtime.async.AbstractAsyncOperation; import com.sun.javafx.runtime.async.AsyncOperationListener; public class LongLongTaskImpl extends AbstractAsyncOperation<Date> { public LongLongTaskImpl(AsyncOperationListener<Date> listener) { super(listener); } // ���ɃR�[������郁�\�b�h @Override public Date call() { try { // 10�b�X���[�v Thread.sleep(10000L); } catch (InterruptedException ex) { // �������̃L�����Z�����s����ƁA // InterruptedException��O���������� // ���̂��߁AInterruptedException��O�������������� // ���₩��call���\�b�h���o��K�v������ } // ���ݎ�����Ԃ� return new Date(); } }
import javafx.async.AbstractAsyncOperation; import java.lang.Exception; import java.lang.Object; import java.util.Date; import com.sun.javafx.runtime.async.AsyncOperationListener; public class LongLongTask extends AbstractAsyncOperation { // �������̌��� public var result: Date; // ���������s��Java�N���X var task: LongLongTaskImpl; public override function start(): Void { // �������̊J�n task = new LongLongTaskImpl(listener); task.start(); } public override function cancel(): Void { // �������̃L�����Z�� task.cancel(); } public override function onCompletion(value: Object): Void { // value��LongLongTaskImpl#call���\�b�h�̖߂�l result = value as Date } }
import javafx.animation.KeyFrame; import javafx.animation.Timeline; import javafx.scene.Scene; import javafx.scene.paint.Color; import javafx.scene.paint.RadialGradient; import javafx.scene.paint.Stop; import javafx.scene.shape.Circle; import javafx.scene.text.Font; import javafx.scene.text.Text; import javafx.stage.Stage; import java.lang.Object; import java.util.Date; // �������̌��ʂ�ێ�������ϐ� var result: Date = new Date(); // ��������5�b���Ƃɍs���^�C�����C�� Timeline { repeatCount: Timeline.INDEFINITE autoReverse: true keyFrames: [ KeyFrame { time: 0s action: function() { // �������N���X�����A���������J�n���� var task: LongLongTask; task = LongLongTask { // ��������ɃR�[�������� onDone: function(flag: Boolean) : Void { result = task.result; } } } }, KeyFrame { time: 5s } ] }.play(); // �{�[�� var ball = Circle { centerX: 0 centerY: 0 radius: 20 fill: RadialGradient { centerX: 0.25 centerY: 0.25 stops: [ Stop { offset: 0.0 color: Color.WHITE }, Stop { offset: 0.6 color: Color.RED } ] } } // �{�[���̐��������̃A�j���[�V���� Timeline { repeatCount: Timeline.INDEFINITE autoReverse: true keyFrames: [ KeyFrame { time: 0s values: ball.translateX => 20.0 }, KeyFrame { time: 2s values: ball.translateX => 280.0 }, ] }.play(); // �{�[���̐��������̃A�j���[�V���� Timeline { repeatCount: Timeline.INDEFINITE autoReverse: true keyFrames: [ KeyFrame { time: 0s values: ball.translateY => 20.0 }, KeyFrame { time: 1.3s values: ball.translateY => 180.0 }, ] }.play(); Stage { title: "Long Long Task" scene: Scene { width: 300 height: 200 content: [ ball, Text { font : Font { size: 20 } x: 10, y: 100 content: bind "{result}" } ] } }