-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.java
74 lines (62 loc) · 2.13 KB
/
Main.java
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
package sample;
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;
import javafx.scene.layout.BorderPane;
import javafx.scene.image.ImageView;
import java.io.File;
public class Main extends Application
{
public static final double DEFAULT_SPEED = 3.0;
public static final int IMAGE_WIDTH = 550, IMAGE_HEIGHT = 400;
public static int stoppedCount = 0;
public static double speed = DEFAULT_SPEED;
public static ImageView currImage;
private boolean clicked = false;
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception
{
BorderPane layout = new BorderPane();
// imageview
currImage = new ImageView();
layout.setMargin(currImage, new Insets(25, 180, 0, 180));
currImage.setSmooth(true);
layout.setTop(currImage);
// add bottom layout
BottomLayout bottomLayoutObject = new BottomLayout(primaryStage);
HBox bottomLayout = bottomLayoutObject.getLayout();
bottomLayout.setAlignment(Pos.BOTTOM_RIGHT);
layout.setBottom(bottomLayout);
currImage.setOnMouseClicked(e ->
{
clicked = !clicked;
if(clicked)
{
BottomLayout.statusBar.setText("Paused");
ImageSelector.timer.cancel();
stoppedCount = ImageSelector.count;
}
else
{
BottomLayout.statusBar.setText("Running the images display");
ImageSelector.startSelectImages(ImageSelector.currPath);
}
});
// cancel the timer if the user exited the program
primaryStage.setOnCloseRequest(e ->
{
if(ImageSelector.timer != null)
ImageSelector.timer.cancel();
});
primaryStage.setTitle("Images Displayer");
primaryStage.setResizable(false);
primaryStage.setScene(new Scene(layout, 900, 600));
primaryStage.show();
}
}