Added a rectangle to play with

This commit is contained in:
Michael-Jouanneau 2016-10-29 21:07:04 +02:00
parent f82b9a8ced
commit e1210440f4
2 changed files with 9 additions and 11 deletions

View File

@ -2,6 +2,7 @@ package sample;
import javafx.application.Application; import javafx.application.Application;
import javafx.fxml.FXMLLoader; import javafx.fxml.FXMLLoader;
import javafx.scene.Node;
import javafx.scene.Parent; import javafx.scene.Parent;
import javafx.scene.Scene; import javafx.scene.Scene;
import javafx.stage.Stage; import javafx.stage.Stage;
@ -15,23 +16,18 @@ public class Main extends Application {
public void start(Stage primaryStage) throws Exception{ public void start(Stage primaryStage) throws Exception{
primaryStage.initStyle(StageStyle.UNDECORATED); primaryStage.initStyle(StageStyle.UNDECORATED);
Parent root = FXMLLoader.load(getClass().getResource("sample.fxml")); Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"));
primaryStage.setTitle("Hello World"); primaryStage.setTitle("Team Avion Launcher [WIP]");
primaryStage.setScene(new Scene(root, 900, 500)); primaryStage.setScene(new Scene(root, 900, 500));
primaryStage.show(); primaryStage.show();
primaryStage.maximizedProperty().addListener((observable, oldValue, newValue) -> { primaryStage.maximizedProperty().addListener((observable, oldValue, newValue) -> {
if (newValue) if (newValue)
primaryStage.setMaximized(false); primaryStage.setMaximized(false);
}); });
root.lookup("#exit").setOnMouseClicked(event -> primaryStage.close()); // Close program if button is clicked root.lookup("#exit").setOnMouseClicked(event -> primaryStage.close());
// Drag // Drag
root.lookup("#dank").setOnMouseDragged(event -> { root.lookup("#rectangle").setOnMouseDragged(event -> {
primaryStage.setX(event.getScreenX());
primaryStage.setY(event.getScreenY());
}); });
} }

View File

@ -2,9 +2,11 @@
<?import javafx.scene.control.Button?> <?import javafx.scene.control.Button?>
<?import javafx.scene.layout.Pane?> <?import javafx.scene.layout.Pane?>
<?import javafx.scene.shape.Rectangle?>
<Pane id="dank" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" xmlns="http://javafx.com/javafx/8.0.102" xmlns:fx="http://javafx.com/fxml/1"> <Pane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="500" prefWidth="900" xmlns="http://javafx.com/javafx/8.0.112-ea" xmlns:fx="http://javafx.com/fxml/1">
<children> <children>
<Button id="exit" alignment="TOP_RIGHT" contentDisplay="RIGHT" mnemonicParsing="false" stylesheets="@../assets/style/nav.css" text="Click if you like Pepe" /> <Button id="exit" alignment="TOP_RIGHT" contentDisplay="RIGHT" layoutX="732.0" layoutY="431.0" mnemonicParsing="false" stylesheets="@../assets/style/nav.css" text="Click if you like Pepe" />
<Rectangle id="rectangle" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="50.0" stroke="BLACK" strokeType="INSIDE" width="900.0" />
</children> </children>
</Pane> </Pane>