package label;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import javafx.scene.Group;
import javafx.scene.shape.*;
import javafx.animation.AnimationTimer;
import javafx.scene.paint.Color;
import javafx.scene.input.MouseEvent;
import javafx.scene.control.Label;
public class pro extends Application {
Label lx;
int time;
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) {
Group root = new Group();
Scene scene = new Scene(root, 700, 700);
time=0;
lx=new Label();
lx.setLayoutX(10);
lx.setLayoutY(10);
lx.setText("ABC");
root.getChildren().add(lx);
primaryStage.setTitle("練習");
primaryStage.setScene(scene);
primaryStage.show();
new AnimationTimer() {
@Override
public void handle(long now) {
time=time+1;
if(time>10){
double p;
p=Math.random();
if(p>0.5)lx.setText("G");
if(p<0.5)lx.setText("H");
time=0;
}
}
}.start();
scene.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent me) {
double mx,my;
mx=me.getX();
my=me.getY();
lx.setText("DFG");
}
});
}
}
最終更新:2013年09月05日 15:17