|
1 | 1 | package gui.collections;
|
2 | 2 |
|
3 |
| -import Client.Client; |
4 |
| -import javafx.collections.FXCollections; |
5 |
| -import javafx.collections.ObservableList; |
6 |
| -import javafx.geometry.Insets; |
7 |
| -import javafx.geometry.Pos; |
| 3 | +import javafx.fxml.FXMLLoader; |
| 4 | +import javafx.scene.Parent; |
8 | 5 | import javafx.scene.Scene;
|
9 |
| -import javafx.scene.control.Button; |
10 |
| -import javafx.scene.control.Label; |
11 |
| -import javafx.scene.control.TableColumn; |
12 |
| -import javafx.scene.control.TableView; |
13 |
| -import javafx.scene.control.cell.PropertyValueFactory; |
14 |
| -import javafx.scene.layout.VBox; |
15 |
| -import javafx.scene.text.Font; |
16 |
| -import javafx.scene.text.FontWeight; |
17 |
| -import javafx.scene.text.Text; |
18 | 6 | import javafx.stage.Stage;
|
19 |
| -import javafx.scene.paint.Color; |
| 7 | + |
| 8 | +import java.io.IOException; |
| 9 | +import java.net.URL; |
20 | 10 |
|
21 | 11 | public class CollectionsWindow {
|
22 | 12 |
|
23 | 13 | private Stage stage;
|
24 | 14 | private Scene scene;
|
25 | 15 |
|
26 | 16 | public CollectionsWindow() {
|
27 |
| - stage = new Stage(); |
28 |
| - VBox root = new VBox(); |
29 |
| - root.setAlignment(Pos.CENTER); |
30 |
| - root.setSpacing(20); |
31 |
| - |
32 |
| - // Username |
33 |
| - Text usernameText = new Text(Client.getInstance().getName()); |
34 |
| - usernameText.setFont(Font.font("Arial", FontWeight.BOLD, 20)); |
35 |
| - usernameText.setFill(Color.web("#333333")); // replace HEX_VALUE with your green color hex code |
36 |
| - |
37 |
| - // Table |
38 |
| - TableView<Object> table = new TableView<>(); // Replace Object with your actual data type |
39 |
| - String[] headers = {"id", "name", "coord X", "coord Y", "creation", "area", "population", "government", "standards", "climate", "governor"}; |
40 |
| - for (String header : headers) { |
41 |
| - TableColumn<Object, String> column = new TableColumn<>(header); // Replace Object with your actual data type |
42 |
| - column.setCellValueFactory(new PropertyValueFactory<>(header.toLowerCase())); |
43 |
| - table.getColumns().add(column); |
| 17 | + try { |
| 18 | + stage = new Stage(); |
| 19 | + URL fxmlLocation = getClass().getResource("/collections/collectionsWindow.fxml"); |
| 20 | + FXMLLoader loader = new FXMLLoader(fxmlLocation); |
| 21 | + Parent root = loader.load(); |
| 22 | + |
| 23 | + scene = new Scene(root, 920, 600); |
| 24 | + stage.setScene(scene); |
| 25 | + } catch (IOException e) { |
| 26 | + e.printStackTrace(); |
44 | 27 | }
|
45 |
| - |
46 |
| - // Dummy data |
47 |
| - ObservableList<Object> data = FXCollections.observableArrayList( |
48 |
| - new Object[] {1, "Vladimir", 56, 800, "990-06-01", 124, 349951, "DEMOCRACY", "VERY HIGH", "STEPPE", "ALEXEY"} // Replace Object with your actual data type |
49 |
| - // Add more dummy data here |
50 |
| - ); |
51 |
| - table.setItems(data); |
52 |
| - |
53 |
| - // Buttons |
54 |
| - Button createButton = new Button("Create"); |
55 |
| - Button editButton = new Button("Edit"); |
56 |
| - Button deleteButton = new Button("Delete"); |
57 |
| - Button visualizeButton = new Button("Visualize"); |
58 |
| - Button commandsButton = new Button("Commands"); |
59 |
| - |
60 |
| - // Action Handlers for buttons |
61 |
| - createButton.setOnAction(event -> { |
62 |
| - // Handle Create button |
63 |
| - }); |
64 |
| - editButton.setOnAction(event -> { |
65 |
| - // Handle Edit button |
66 |
| - }); |
67 |
| - deleteButton.setOnAction(event -> { |
68 |
| - // Handle Delete button |
69 |
| - }); |
70 |
| - visualizeButton.setOnAction(event -> { |
71 |
| - // Handle Visualize button |
72 |
| - }); |
73 |
| - commandsButton.setOnAction(event -> { |
74 |
| - // Handle Commands button |
75 |
| - }); |
76 |
| - |
77 |
| - // Adding elements to the layout |
78 |
| - root.getChildren().addAll(usernameText, table, createButton, editButton, deleteButton, visualizeButton, commandsButton); |
79 |
| - |
80 |
| - scene = new Scene(root, 500, 500); |
81 |
| - stage.setScene(scene); |
82 | 28 | }
|
83 | 29 |
|
84 | 30 | public void show() {
|
|
0 commit comments