Adds drag
This commit is contained in:
parent
d7340c255d
commit
9b2ff92d4c
@ -1,3 +1,7 @@
|
|||||||
#exit{
|
#exit{
|
||||||
-fx-background-color: rgba(255, 0, 255, 0.5);
|
-fx-background-color: rgba(255, 0, 255, 0.5);
|
||||||
|
-fx-background-radius: 0;
|
||||||
|
}
|
||||||
|
#exit:hover{
|
||||||
|
-fx-background-color: rgba(0, 0, 255, 0.5);
|
||||||
}
|
}
|
@ -9,9 +9,11 @@ import javafx.stage.StageStyle;
|
|||||||
|
|
||||||
public class Main extends Application {
|
public class Main extends Application {
|
||||||
|
|
||||||
|
volatile double[] posOrigin = {0, 0};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start(Stage primaryStage) throws Exception{
|
public void start(Stage primaryStage) throws Exception{
|
||||||
primaryStage.initStyle(StageStyle.UNIFIED);
|
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("Hello World");
|
||||||
primaryStage.setScene(new Scene(root, 900, 500));
|
primaryStage.setScene(new Scene(root, 900, 500));
|
||||||
@ -21,6 +23,16 @@ public class Main extends Application {
|
|||||||
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()); // Close program if button is clicked
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Drag
|
||||||
|
root.lookup("#dank").setOnMouseDragged(event -> {
|
||||||
|
primaryStage.setX(event.getScreenX());
|
||||||
|
primaryStage.setY(event.getScreenY());
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
<?import javafx.scene.control.Button?>
|
<?import javafx.scene.control.Button?>
|
||||||
<?import javafx.scene.layout.Pane?>
|
<?import javafx.scene.layout.Pane?>
|
||||||
|
|
||||||
<Pane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.102" xmlns:fx="http://javafx.com/fxml/1">
|
<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">
|
||||||
<children>
|
<children>
|
||||||
<Button id="exit" fx:id="pepe" alignment="TOP_RIGHT" contentDisplay="RIGHT" mnemonicParsing="false" stylesheets="@../assets/nav.css" text="Click if you like Pepe" />
|
<Button id="exit" alignment="TOP_RIGHT" contentDisplay="RIGHT" mnemonicParsing="false" stylesheets="@../assets/nav.css" text="Click if you like Pepe" />
|
||||||
</children>
|
</children>
|
||||||
</Pane>
|
</Pane>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user