Repository navigation
Expand file tree
/
Copy pathTela.java
More file actions
99 lines (77 loc) · 2.76 KB
/
Copy pathTela.java
File metadata and controls
99 lines (77 loc) · 2.76 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.HBox;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.stage.FileChooser;
import javafx.stage.Stage;
public class Tela extends Application {
Scene scene1, scene2;
Stage window;
int clock = 0;
Button button;
ImageView selectedImage;
MaquinaEstados maqEstados;
String arquivo;
@Override
public void start(Stage primaryStage) throws Exception {
window = primaryStage;
// Button 1
Label label1 = new Label("Welcome to our mips simulator!");
Button button1 = new Button("Choose the .mips file");
button1.setOnAction(e -> {
FileChooser fileChooser = new FileChooser();
File file = fileChooser.showOpenDialog(window);
arquivo = String.valueOf(file.getAbsolutePath());
try {
window.setScene(getScene2(arquivo));
} catch (FileNotFoundException e1) {
e1.printStackTrace();
}
});
//Layout 1 - children laid out in vertical column
VBox layout1 = new VBox(20);
layout1.setAlignment(Pos.CENTER);
layout1.getChildren().addAll(label1, button1);
scene1 = new Scene(layout1, 300, 300);
window.setScene(scene1);
window.show();
}
public Scene getScene2(String arquivo) throws FileNotFoundException {
maqEstados = new MaquinaEstados(arquivo);
//Creating label
Label label = new Label("Estado atual: busca");
//Taking care of image display
selectedImage = new ImageView();
selectedImage.setImage(maqEstados.getImBusca());
//Creating button
button = new Button("Next");
VBox vbox = new VBox();
vbox.setAlignment(Pos.CENTER);
vbox.setSpacing(50);
vbox.getChildren().addAll(label,selectedImage,button);
StackPane layout = new StackPane();
layout.getChildren().add(vbox);
//Taking care of button
button.setOnAction(e -> {
clock++;
Image im = maqEstados.getProxEstado();
selectedImage.setImage(im);
label.setText("Estado atual: "+maqEstados.getEstadoAtual());
});
scene2 = new Scene(layout, 1200, 800);
return scene2;
}
public static void main(String[] args) {
launch(args);
}
}