4
4
import javafx .fxml .FXMLLoader ;
5
5
import javafx .scene .Parent ;
6
6
import javafx .scene .Scene ;
7
+ import javafx .scene .control .Button ;
8
+ import javafx .scene .control .Hyperlink ;
7
9
import javafx .scene .layout .BorderPane ;
10
+ import javafx .scene .layout .HBox ;
11
+ import javafx .scene .layout .VBox ;
12
+ import javafx .scene .text .Font ;
13
+ import javafx .scene .text .FontWeight ;
14
+ import javafx .scene .text .Text ;
8
15
import javafx .stage .Stage ;
9
16
import net .aksingh .owmjapis .api .APIException ;
10
17
import sample .SerialPortService ;
@@ -39,6 +46,47 @@ public static void main(String[] args) {
39
46
launch (args );
40
47
}
41
48
49
+ public HBox addHBox (){
50
+ HBox hbox = new HBox ();
51
+ hbox .setPadding (new Insets (15 ,12 ,15 ,12 ));
52
+ hbox .setSpacing (10 );
53
+ hbox .setStyle ("-fx-background-color: #336699;" );
54
+
55
+ Button buttonCurrent = new Button ("Outdoor Temperature" );
56
+ buttonCurrent .setPrefSize (100 ,20 );
57
+
58
+ Button buttonProjected = new Button ("Indoor Temperature" );
59
+ buttonProjected .setPrefSize (100 ,20 );
60
+ hbox .getChildren ().addAll (buttonCurrent ,buttonProjected );
61
+
62
+ return hbox ;
63
+ }
64
+
65
+ public VBox addVBox (){
66
+ VBox vbox = new VBox ();
67
+ vbox .setPadding (new Insets (10 ));
68
+ vbox .setSpacing (8 );
69
+
70
+ Text title = new Text ("Data" );
71
+ title .setFont (Font .font ("Arial" , FontWeight .BOLD ,14 ));
72
+ vbox .getChildren ().add (title );
73
+
74
+ Hyperlink options [] = new Hyperlink [] {
75
+ new Hyperlink ("Sales" ),
76
+ new Hyperlink ("Marketing" ),
77
+ new Hyperlink ("Distribution" ),
78
+ new Hyperlink ("Costs" )};
79
+
80
+ for (int i =0 ; i <4 ; i ++) {
81
+ VBox .setMargin (options [i ], new Insets (0 , 0 , 0 , 8 ));
82
+ vbox .getChildren ().add (options [i ]);
83
+ }
84
+
85
+ return vbox ;
86
+ }
87
+
88
+
89
+
42
90
@ Override
43
91
public void start (Stage primaryStage ) {
44
92
/*var sp = SerialPortService.getSerialPort("COM3");
@@ -80,8 +128,12 @@ public void start(Stage primaryStage) {
80
128
CountdownHandler part, timer for CountdownHandler
81
129
*/
82
130
131
+ // Here we are testing the Borderpane layout
83
132
var pane = new BorderPane ();
84
133
var label = new Label ();
134
+ HBox hbox = addHBox ();
135
+ pane .setTop (hbox );
136
+ pane .setCenter (addVBox ());
85
137
86
138
// Getting temperature data from the OpenWeather API class
87
139
try {
@@ -97,11 +149,11 @@ public void start(Stage primaryStage) {
97
149
98
150
//label.setText(name);
99
151
100
- pane .setCenter (label );
101
- pane .setPadding (new Insets (0 , 20 , 0 , 20 ));
152
+ // pane.setCenter(label);
153
+ // pane.setPadding(new Insets(0, 20, 0, 20));
102
154
//pane.setStyle("")
103
155
104
- var scene = new Scene (pane , 400 , 200 );
156
+ var scene = new Scene (pane , 400 , 400 );
105
157
106
158
primaryStage .setScene (scene );
107
159
primaryStage .show ();
0 commit comments