generated from programacionThiar/plantilla_iesthiar_javafx
Initial commit
This commit is contained in:
38
src/main/java/iesthiar/App.java
Normal file
38
src/main/java/iesthiar/App.java
Normal file
@@ -0,0 +1,38 @@
|
||||
package iesthiar;
|
||||
|
||||
import javafx.application.Application;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* JavaFX App
|
||||
*/
|
||||
public class App extends Application {
|
||||
|
||||
private static Scene scene;
|
||||
|
||||
@Override
|
||||
public void start(Stage stage) throws IOException {
|
||||
scene = new Scene(loadFXML("primary"), 640, 480);
|
||||
stage.setScene(scene);
|
||||
stage.show();
|
||||
}
|
||||
|
||||
static void setRoot(String fxml) throws IOException {
|
||||
scene.setRoot(loadFXML(fxml));
|
||||
}
|
||||
|
||||
private static Parent loadFXML(String fxml) throws IOException {
|
||||
FXMLLoader fxmlLoader = new FXMLLoader(App.class.getResource(fxml + ".fxml"));
|
||||
return fxmlLoader.load();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
launch();
|
||||
}
|
||||
|
||||
}
|
||||
12
src/main/java/iesthiar/PrimaryController.java
Normal file
12
src/main/java/iesthiar/PrimaryController.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package iesthiar;
|
||||
|
||||
import java.io.IOException;
|
||||
import javafx.fxml.FXML;
|
||||
|
||||
public class PrimaryController {
|
||||
|
||||
@FXML
|
||||
private void switchToSecondary() throws IOException {
|
||||
App.setRoot("secondary");
|
||||
}
|
||||
}
|
||||
12
src/main/java/iesthiar/SecondaryController.java
Normal file
12
src/main/java/iesthiar/SecondaryController.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package iesthiar;
|
||||
|
||||
import java.io.IOException;
|
||||
import javafx.fxml.FXML;
|
||||
|
||||
public class SecondaryController {
|
||||
|
||||
@FXML
|
||||
private void switchToPrimary() throws IOException {
|
||||
App.setRoot("primary");
|
||||
}
|
||||
}
|
||||
7
src/main/java/module-info.java
Normal file
7
src/main/java/module-info.java
Normal file
@@ -0,0 +1,7 @@
|
||||
module iesthiar {
|
||||
requires javafx.controls;
|
||||
requires javafx.fxml;
|
||||
|
||||
opens iesthiar to javafx.fxml;
|
||||
exports iesthiar;
|
||||
}
|
||||
16
src/main/resources/iesthiar/primary.fxml
Normal file
16
src/main/resources/iesthiar/primary.fxml
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.control.Button?>
|
||||
<?import javafx.geometry.Insets?>
|
||||
|
||||
<VBox alignment="CENTER" spacing="20.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="iesthiar.PrimaryController">
|
||||
<children>
|
||||
<Label text="Primary View" />
|
||||
<Button fx:id="primaryButton" text="Switch to Secondary View" onAction="#switchToSecondary"/>
|
||||
</children>
|
||||
<padding>
|
||||
<Insets bottom="20.0" left="20.0" right="20.0" top="20.0" />
|
||||
</padding>
|
||||
</VBox>
|
||||
16
src/main/resources/iesthiar/secondary.fxml
Normal file
16
src/main/resources/iesthiar/secondary.fxml
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.control.Button?>
|
||||
<?import javafx.geometry.Insets?>
|
||||
|
||||
<VBox alignment="CENTER" spacing="20.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="iesthiar.SecondaryController">
|
||||
<children>
|
||||
<Label text="Secondary View" />
|
||||
<Button fx:id="secondaryButton" text="Switch to Primary View" onAction="#switchToPrimary" />
|
||||
</children>
|
||||
<padding>
|
||||
<Insets bottom="20.0" left="20.0" right="20.0" top="20.0" />
|
||||
</padding>
|
||||
</VBox>
|
||||
Reference in New Issue
Block a user