Skip to content
Snippets Groups Projects
Commit 68dbc7e7 authored by Dina's avatar Dina
Browse files

deleted GuiDriver and FxmlGuiDriver

parent 0ad13789
No related branches found
No related tags found
No related merge requests found
package org.example;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
/**
* Driver class for a simple JavaFX demonstration.
*
*/
public class FxmlGuiDriver extends Application {
private static final Logger log = LogManager.getLogger(FxmlGuiDriver.class);
/**
* @param args unused
*/
public static void main(String[] args) {
launch(args);
}
public void start(Stage stage) throws Exception {
log.info("Starting Hello JavaFX and Maven demonstration application");
final String fxmlFile = "/fxml/hello.fxml";
log.debug("Loading FXML for main view from: {}", fxmlFile);
final FXMLLoader loader = new FXMLLoader();
final Parent rootNode = (Parent) loader.load(getClass().getResourceAsStream(fxmlFile));
log.debug("Showing JFX scene");
final Scene scene = new Scene(rootNode, 400, 200);
//scene.getStylesheets().add("/styles/styles.css");
stage.setTitle("Hello JavaFX and Maven");
stage.setScene(scene);
stage.show();
}
}
package org.example;
import org.example.GuiHelper.Dialog;
import org.example.GuiHelper.NumberField;
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import javafx.stage.Stage;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class GuiDriver extends Application {
private static Logger log = LogManager.getLogger(GuiDriver.class);
private final static int
colIndex_0 = 0,
colIndex_1 = 1;
private final Button resetBtn = new Button(Conf.get("resetButton.text"));
private final TextField nameField = new TextField();
private final NumberField ageField = new NumberField();
public static void main(String[] args) {
launch(args);
}
public GuiDriver() {
resetBtn.setDisable(true);
nameField.textProperty().addListener(event -> {
log.info("Name value '" + nameField.getText() + "' has been entered");
resetBtn.setDisable(false);
});
ageField.textProperty().addListener(event -> {
log.info("Age value '" + ageField.getText() + "' has been entered");
resetBtn.setDisable(false);
});
resetBtn.setOnAction(event -> {
nameField.setText("");
ageField.setText("");
resetBtn.setDisable(true);
Dialog.showInfo(Conf.get("infoFieldReset"));
log.info("re-setting name field");
});
}
@Override
public void start(final Stage primaryStage) {
primaryStage.setTitle("Sample GUI");
final GridPane grid = new GridPane();
grid.setAlignment(Pos.CENTER);
grid.setHgap(10);
grid.setVgap(10);
grid.setPadding(new Insets(25, 25, 25, 25));
int currentRowIndex = 0;
final Text scenetitle = new Text("Simple GUI example");
scenetitle.setFont(Font.font("Tahoma", FontWeight.NORMAL, 20));
grid.add(scenetitle, colIndex_0, currentRowIndex, 2, 1);
currentRowIndex++;
grid.add(new Label("Your name:"), colIndex_0, currentRowIndex);
grid.add(nameField, colIndex_1, currentRowIndex);
currentRowIndex++;
grid.add(new Label("Your age:"), colIndex_0, currentRowIndex);
grid.add(ageField, colIndex_1, currentRowIndex);
currentRowIndex++;
grid.add(resetBtn, colIndex_0, currentRowIndex);
final Scene scene = new Scene(grid, 300, 250);
primaryStage.setScene(scene);
primaryStage.show();
}
@Override
public void stop() throws Exception {
super.stop();
log.info("Terminating application");
}
}
\ No newline at end of file
......@@ -5,7 +5,7 @@
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?>
<GridPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/17.0.2-ea" xmlns:fx="http://javafx.com/fxml/1">
<GridPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="500.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/17.0.2-ea" xmlns:fx="http://javafx.com/fxml/1">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment