-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRecord.java
More file actions
86 lines (71 loc) · 2.36 KB
/
Record.java
File metadata and controls
86 lines (71 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.stage.Stage;
import javafx.scene.control.Label;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.Background;
import javafx.scene.layout.VBox;
import javafx.concurrent.Task;
public class Record extends Application
{
// declare some constants
private static final int NUMBER_OF_IMAGES = 8;
private static final int SLEEP_TIME = 100;
private Label label = new Label();
@Override
public void start (Stage stage)
{
VBox root = new VBox();
root.setBackground(Background.EMPTY);
root.setAlignment(Pos.CENTER);
root.getChildren().add(label);
Scene scene = new Scene(root, 300, 300);
stage.setScene(scene);
stage.setTitle("Record");
stage.show();
begin(stage);
}
private void begin(Stage stageIn) // helper method
{
// create an image from a file and add it to a label
ImageView imageView = new ImageView();
label.setGraphic(imageView);
Thread thread1 = new Thread(new Task<Void>() // anonymous class
{
String imageFileName;
int currentImage = 1;
Image image;
@Override
protected Void call()
{
while(stageIn.isShowing())
{
// create the name of the next image to be used
imageFileName = "record" + currentImage + ".jpg";
image = new Image(imageFileName);
imageView.setImage(image);
try
{
Thread.sleep(SLEEP_TIME);
}
catch(InterruptedException e)
{
}
currentImage++; // next image
if(currentImage == NUMBER_OF_IMAGES + 1)
{
currentImage = 1;
}
}
return null;
}
});
thread1.start();
}
public static void main(String[] args)
{
launch(args);
}
}