Work on SettingsWindow and Server
This commit is contained in:
@@ -25,6 +25,11 @@
|
||||
<artifactId>javafx-fxml</artifactId>
|
||||
<version>${javafx.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openjfx</groupId>
|
||||
<artifactId>javafx-graphics</artifactId>
|
||||
<version>${javafx.version}</version> <!-- Update to the JavaFX version you are using -->
|
||||
</dependency>
|
||||
<!-- Other dependencies can be added here as needed -->
|
||||
</dependencies>
|
||||
|
||||
|
@@ -131,7 +131,7 @@ public class MainLayout extends BorderPane {
|
||||
this.setCenter(galleryLayout);
|
||||
}
|
||||
private void switchToSettingsLayout() {
|
||||
SettingsLayout settingsLayout = new SettingsLayout();
|
||||
SettingsWindow settingsLayout = new SettingsWindow();
|
||||
this.setCenter(settingsLayout);
|
||||
}
|
||||
}
|
||||
|
@@ -1,26 +0,0 @@
|
||||
package com.example.bricklog.view;
|
||||
|
||||
import javafx.geometry.Insets;
|
||||
//import javafx.geometry.Pos;
|
||||
import javafx.scene.control.CheckBox;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.layout.VBox;
|
||||
|
||||
public class SettingsLayout extends VBox {
|
||||
|
||||
public SettingsLayout() {
|
||||
this.setSpacing(10);
|
||||
this.setPadding(new Insets(20));
|
||||
|
||||
Label settingsTitle = new Label("Settings");
|
||||
settingsTitle.setStyle("-fx-font-size: 20px; -fx-font-weight: bold;");
|
||||
|
||||
// Example settings: toggle for sound, username input
|
||||
CheckBox soundToggle = new CheckBox("Enable Sound");
|
||||
TextField usernameField = new TextField();
|
||||
usernameField.setPromptText("Enter your username");
|
||||
|
||||
this.getChildren().addAll(settingsTitle, soundToggle, usernameField);
|
||||
}
|
||||
}
|
@@ -0,0 +1,118 @@
|
||||
package com.example.bricklog.view;
|
||||
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.CheckBox;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.layout.BorderPane;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.scene.layout.VBox;
|
||||
import static javafx.scene.paint.Color.WHITE;
|
||||
import javafx.scene.text.Font;
|
||||
|
||||
public class SettingsWindow extends BorderPane {
|
||||
|
||||
private final StackPane contentPane;
|
||||
private final VBox generalSettings;
|
||||
private final VBox serverSettings;
|
||||
private final Label connectionStatus;
|
||||
|
||||
public SettingsWindow() {
|
||||
// Menu on the left side for navigation
|
||||
VBox menu = new VBox();
|
||||
menu.setSpacing(10);
|
||||
menu.setPadding(new Insets(10));
|
||||
menu.setStyle("-fx-background-color: #f0f0f0;");
|
||||
|
||||
// Labels for the menu
|
||||
Label generalLabel = new Label("General");
|
||||
generalLabel.setStyle("-fx-font-weight: bold; cursor: hand;");
|
||||
generalLabel.setOnMouseClicked(event -> showGeneralSettings());
|
||||
|
||||
Label serverLabel = new Label("Server");
|
||||
serverLabel.setStyle("-fx-font-weight: bold; cursor: hand;");
|
||||
serverLabel.setOnMouseClicked(event -> showServerSettings());
|
||||
|
||||
menu.getChildren().addAll(generalLabel, serverLabel);
|
||||
this.setLeft(menu);
|
||||
|
||||
// StackPane to hold different settings panels
|
||||
contentPane = new StackPane();
|
||||
this.setCenter(contentPane);
|
||||
|
||||
// Define General Settings panel
|
||||
generalSettings = new VBox(10);
|
||||
generalSettings.setPadding(new Insets(15));
|
||||
generalSettings.setAlignment(Pos.TOP_LEFT);
|
||||
Label themeLabel = new Label("Theme:");
|
||||
CheckBox darkTheme = new CheckBox("Dark Theme");
|
||||
|
||||
Label layoutLabel = new Label("Layout:");
|
||||
CheckBox compactLayout = new CheckBox("Compact Layout");
|
||||
|
||||
generalSettings.getChildren().addAll(themeLabel, darkTheme, layoutLabel, compactLayout);
|
||||
|
||||
// Define Server Settings panel
|
||||
serverSettings = new VBox(10);
|
||||
serverSettings.setPadding(new Insets(15));
|
||||
serverSettings.setAlignment(Pos.TOP_LEFT);
|
||||
|
||||
// Connection Status Label
|
||||
connectionStatus = new Label("Server Status: Not Connected");
|
||||
connectionStatus.setFont(new Font("Arial", 14));
|
||||
connectionStatus.setTextFill(WHITE);
|
||||
connectionStatus.setStyle("-fx-background-color: lightpink; -fx-padding: 5;");
|
||||
connectionStatus.setAlignment(Pos.CENTER);
|
||||
connectionStatus.setMaxWidth(Double.MAX_VALUE);
|
||||
|
||||
// Server IP field & Connect button
|
||||
Label ipLabel = new Label("Server IP:");
|
||||
TextField ipField = new TextField();
|
||||
ipField.setPromptText("Enter server IP address...");
|
||||
|
||||
Button connectButton = new Button("Connect");
|
||||
connectButton.setOnAction(event -> connectToServer(ipField.getText()));
|
||||
|
||||
serverSettings.getChildren().addAll(connectionStatus, ipLabel, ipField, connectButton);
|
||||
|
||||
|
||||
// Add panels to contentPane and show the default panel
|
||||
contentPane.getChildren().addAll(generalSettings, serverSettings);
|
||||
showGeneralSettings(); // Default to showing the general settings
|
||||
}
|
||||
|
||||
// Method to show the General Settings panel
|
||||
private void showGeneralSettings() {
|
||||
generalSettings.setVisible(true);
|
||||
generalSettings.toFront();
|
||||
serverSettings.setVisible(false);
|
||||
}
|
||||
|
||||
// Method to show the Server Settings panel
|
||||
private void showServerSettings() {
|
||||
serverSettings.setVisible(true);
|
||||
serverSettings.toFront();
|
||||
generalSettings.setVisible(false);
|
||||
}
|
||||
|
||||
// Method to connect to the server
|
||||
private void connectToServer(String ipAddress) {
|
||||
boolean isConnected = simulateServerConnection(ipAddress); // Replace with real connection logic
|
||||
|
||||
if (isConnected) {
|
||||
connectionStatus.setText("Connected");
|
||||
connectionStatus.setStyle("-fx-background-color: lightgreen; -fx-padding: 5;");
|
||||
} else {
|
||||
connectionStatus.setText("Not Connected");
|
||||
connectionStatus.setStyle("-fx-background-color: lightpink; -fx-padding: 5;");
|
||||
}
|
||||
}
|
||||
|
||||
// Simulated connection logic for demonstration purposes
|
||||
private boolean simulateServerConnection(String ipAddress) {
|
||||
// Here, add logic for real server connection. For now, a simple placeholder:
|
||||
return !ipAddress.isEmpty() && ipAddress.equals("127.0.0.1");
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,3 +1,4 @@
|
||||
com\example\bricklog\BrickLogClientApplication.class
|
||||
com\example\bricklog\view\MainLayout.class
|
||||
com\example\bricklog\view\SettingsWindow.class
|
||||
com\example\bricklog\view\GalleryLayout.class
|
||||
|
Reference in New Issue
Block a user