-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
54 lines (45 loc) · 1.61 KB
/
Main.java
File metadata and controls
54 lines (45 loc) · 1.61 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
import javafx.animation.KeyFrame;
import javafx.animation.KeyValue;
import javafx.animation.Timeline;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.geometry.Insets;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.image.Image;
import javafx.stage.Stage;
import javafx.util.Duration;
import java.io.IOException;
public class Main extends Application {
@Override
public void start(Stage stage) throws IOException {
// 加载主场景
Parent root = FXMLLoader.load(getClass().getResource("Main.fxml"));
Scene scene = new Scene(root);
scene.getStylesheets().add(getClass().getResource("Style/Main.css").toExternalForm());
// 设置窗口标题
stage.setTitle("落秋的闲暇时光");
// 设置窗口图标
Image icon = new Image(getClass().getResourceAsStream("icons/icon.jpg"));
stage.getIcons().add(icon);
// 设置场景
stage.setScene(scene);
// 显示窗口
stage.show();
}
@FXML
private void goToLogin(ActionEvent event) throws IOException {
Stage stage = (Stage) ((Node) event.getSource()).getScene().getWindow();
Parent root = FXMLLoader.load(getClass().getResource("/User/Login.fxml")); // Assuming Login.fxml is in User/Login directory
Scene scene = new Scene(root);
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}