Skip to content
Snippets Groups Projects
Commit 7be14839 authored by Daniel Schmidt's avatar Daniel Schmidt
Browse files

WIP

parent 0831b8e7
No related branches found
No related tags found
No related merge requests found
package ui.shared;
import java.io.IOException;
import java.util.Timer;
import java.util.TimerTask;
import javafx.application.Application;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
......@@ -33,7 +37,7 @@ public class MainApp extends Application {
* Show a screen in the center of the main window
*
* @param location
* path to fxml file
* path to fxml file (without screen)
* @return
*/
public ConnectedControl showScreen(String location) {
......@@ -61,8 +65,8 @@ public class MainApp extends Application {
loader.setLocation(MainApp.class.getResource("RootLayout.fxml"));
rootLayout = (BorderPane) loader.load();
// Show the scene containing the root layout.
Scene scene = new Scene(rootLayout);
addResizeListener();
primaryStage.setScene(scene);
primaryStage.show();
} catch (IOException e) {
......@@ -70,6 +74,36 @@ public class MainApp extends Application {
}
}
private void addResizeListener() {
ChangeListener<Number> listener = new ChangeListener<Number>() {
final Timer timer = new Timer(); // uses a timer to call your
// resize method
TimerTask task = null; // task to execute after defined delay
final long delayTime = 200; // delay that has to pass in order
// to consider an operation done
public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
if (task != null) { // there was already a task scheduled
// from the previous operation ...
task.cancel(); // cancel it, we have a new size to
// consider
}
task = new TimerTask() {
@Override
public void run() {
// here you can place your resize code
System.out.println("resize to " + primaryStage.getWidth() + " " + primaryStage.getHeight());
}
};
// schedule new task
timer.schedule(task, delayTime);
}
};
primaryStage.widthProperty().addListener(listener);
primaryStage.heightProperty().addListener(listener);
}
/**
* Returns the main stage.
*
......
......@@ -6,11 +6,9 @@
<?import javafx.scene.layout.*?>
<?import javafx.scene.layout.AnchorPane?>
<AnchorPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308"
xmlns="http://javafx.com/javafx/8.0.40" xmlns:fx="http://javafx.com/fxml/1"
fx:controller="ui.shared.ModeSelectScreen">
<AnchorPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="400.0" minWidth="600.0" xmlns="http://javafx.com/javafx/8.0.40" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ui.shared.ModeSelectScreen">
<children>
<GridPane prefHeight="431.0" prefWidth="528.0">
<GridPane gridLinesVisible="true" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="400.0" minWidth="600.0">
<columnConstraints>
<ColumnConstraints hgrow="ALWAYS" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="ALWAYS" minWidth="10.0" prefWidth="100.0" />
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment