Tabs :D
This commit is contained in:
parent
fe7b1ca957
commit
a0f74457b3
@ -18,23 +18,23 @@ import javafx.scene.layout.Pane;
|
|||||||
import javafx.scene.shape.Rectangle;
|
import javafx.scene.shape.Rectangle;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
import javafx.stage.StageStyle;
|
import javafx.stage.StageStyle;
|
||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
public class Main extends Application {
|
public class Main extends Application {
|
||||||
|
|
||||||
public static final URL mainLauncher = Main.class.getResource("../assets/layout/main.fxml"); // Launcher body
|
public static final URL mainLauncher = Main.class.getResource("../assets/layout/main.fxml"); // Launcher body
|
||||||
public static final URL homeTab = Main.class.getResource("../assets/layout/home.fxml"); // Launcher home tab
|
|
||||||
|
|
||||||
private double xOffset = 0, yOffset = 0; // Offsets for dragging
|
private double xOffset = 0, yOffset = 0; // Offsets for dragging
|
||||||
private Button exit, min, Home_btn, Modpack_btn; // Define buttons
|
private Button exit, min, Home_btn, Modpack_btn; // Define buttons
|
||||||
private Rectangle dragBar; // Draggable top bar
|
private Rectangle dragBar; // Draggable top bar
|
||||||
|
private Pane root, tab;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start(Stage primaryStage) throws Exception{
|
public void start(Stage primaryStage) throws Exception{
|
||||||
|
|
||||||
primaryStage.initStyle(StageStyle.UNDECORATED);
|
primaryStage.initStyle(StageStyle.UNDECORATED); // Remove ugly trash
|
||||||
Pane root = FXMLLoader.load(mainLauncher);
|
|
||||||
|
root = FXMLLoader.load(mainLauncher);
|
||||||
primaryStage.setTitle("Team-Avion Launcher [WIP]");
|
primaryStage.setTitle("Team-Avion Launcher [WIP]");
|
||||||
primaryStage.setScene(new Scene(root, 900, 500));
|
primaryStage.setScene(new Scene(root, 900, 500));
|
||||||
primaryStage.show();
|
primaryStage.show();
|
||||||
@ -46,7 +46,7 @@ public class Main extends Application {
|
|||||||
dragBar = (Rectangle) root.lookup("#rectangle");
|
dragBar = (Rectangle) root.lookup("#rectangle");
|
||||||
Home_btn = (Button) root.lookup("#Home-btn");
|
Home_btn = (Button) root.lookup("#Home-btn");
|
||||||
Modpack_btn = (Button) root.lookup("#Modpacks-btn");
|
Modpack_btn = (Button) root.lookup("#Modpacks-btn");
|
||||||
|
tab = (Pane) root.lookup("#tab");
|
||||||
|
|
||||||
// Infrastructural navigation
|
// Infrastructural navigation
|
||||||
exit.setOnMouseClicked(event -> primaryStage.close());
|
exit.setOnMouseClicked(event -> primaryStage.close());
|
||||||
@ -61,9 +61,14 @@ public class Main extends Application {
|
|||||||
primaryStage.setX(event.getScreenX() - xOffset);
|
primaryStage.setX(event.getScreenX() - xOffset);
|
||||||
primaryStage.setY(event.getScreenY() - yOffset);
|
primaryStage.setY(event.getScreenY() - yOffset);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Set up default layout
|
||||||
|
Tabs.Home.switchTab(tab);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
launch(args);
|
launch(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
26
src/Launcher/Tabs.java
Normal file
26
src/Launcher/Tabs.java
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
package Launcher;
|
||||||
|
|
||||||
|
import javafx.fxml.FXMLLoader;
|
||||||
|
import javafx.scene.layout.Pane;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
public enum Tabs {
|
||||||
|
|
||||||
|
Modpacks(Main.class.getResource("../assets/layout/modpacks.fxml")), Home(Main.class.getResource("../assets/layout/home.fxml"));
|
||||||
|
|
||||||
|
public final URL url;
|
||||||
|
Tabs(URL url){
|
||||||
|
this.url = url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void switchTab(Pane holder){
|
||||||
|
holder.getChildren().clear();
|
||||||
|
try {
|
||||||
|
holder.getChildren().add(FXMLLoader.load(url));
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
0
src/assets/layout/modpacks.fxml
Normal file
0
src/assets/layout/modpacks.fxml
Normal file
Loading…
x
Reference in New Issue
Block a user