File tree 5 files changed +22
-7
lines changed
5 files changed +22
-7
lines changed Original file line number Diff line number Diff line change 5
5
This project is :
6
6
* Maven + JavaFX + Openjdk 12 + Eclipse
7
7
* an example with custom css
8
- * an example of a JavaFX Task
8
+ * with borderless window
9
+ * drag and drop of the window
10
+ * a window close button
11
+ * an example of a JavaFX background Task
9
12
10
13
![ ] ( https://github.com/neokeld/JavaFXDesign/blob/master/readme-assets/1.png )
11
14
12
15
This project is also :
13
16
* a fiction with a delivery management company Deliverat
14
- * featuring Maïté
17
+ * featuring [ Maïté] ( https://fr.wikipedia.org/wiki/Ma%C3%AFt%C3%A9 )
15
18
* the purple color from https://v2.grommet.io/
16
- * no close button...
17
19
* based on https://github.com/k33ptoo/RestaurantMgtSampleUI
Original file line number Diff line number Diff line change 1
1
package design ;
2
2
3
+ import javafx .application .Platform ;
3
4
import javafx .event .ActionEvent ;
4
5
import javafx .fxml .FXML ;
5
6
import javafx .fxml .FXMLLoader ;
@@ -59,6 +60,9 @@ public class Controller implements Initializable {
59
60
60
61
@ FXML
61
62
private Pane pnlSignout ;
63
+
64
+ @ FXML
65
+ private Button btnCloseWindow ;
62
66
63
67
@ Override
64
68
public void initialize (URL location , ResourceBundle resources ) {
@@ -119,4 +123,8 @@ public void handleClicks(ActionEvent actionEvent) {
119
123
pnlSignout .toFront ();
120
124
}
121
125
}
126
+
127
+ public void handleCloseWindow () {
128
+ Platform .exit ();
129
+ }
122
130
}
Original file line number Diff line number Diff line change 230
230
</Pane >
231
231
</children >
232
232
</StackPane >
233
+ <Button fx : id =" btnCloseWindow" layoutX =" 1024.0" layoutY =" 4.0" mnemonicParsing =" false" onAction =" #handleCloseWindow" prefHeight =" 20.0" prefWidth =" 21.0" style =" -fx-border-color: transparent; -fx-background-color: transparent;" stylesheets =" @style.css" text =" X" >
234
+ <HBox .margin>
235
+ <Insets />
236
+ </HBox .margin>
237
+ </Button >
233
238
</children >
234
239
<effect >
235
240
<DropShadow color =" #1b1eeb" />
Original file line number Diff line number Diff line change 10
10
import javafx .stage .StageStyle ;
11
11
12
12
public class Main extends Application {
13
- private double x , y ;
13
+ private double x ;
14
+ private double y ;
14
15
15
16
@ Override
16
17
public void start (Stage primaryStage ) throws Exception {
@@ -19,17 +20,16 @@ public void start(Stage primaryStage) throws Exception {
19
20
//set stage borderless
20
21
primaryStage .initStyle (StageStyle .UNDECORATED );
21
22
22
- //drag it here
23
+ //window drag and drop
23
24
root .setOnMousePressed (event -> {
24
25
x = event .getSceneX ();
25
26
y = event .getSceneY ();
26
27
});
27
28
root .setOnMouseDragged (event -> {
28
-
29
29
primaryStage .setX (event .getScreenX () - x );
30
30
primaryStage .setY (event .getScreenY () - y );
31
-
32
31
});
32
+
33
33
primaryStage .show ();
34
34
}
35
35
You can’t perform that action at this time.
0 commit comments