File tree Expand file tree Collapse file tree 4 files changed +125
-0
lines changed Expand file tree Collapse file tree 4 files changed +125
-0
lines changed Original file line number Diff line number Diff line change 1+ package part5javafx ;
2+
3+ import javafx .application .Application ;
4+ import javafx .scene .Scene ;
5+ import javafx .scene .control .Label ;
6+ import javafx .scene .layout .VBox ;
7+ import javafx .scene .text .Font ;
8+ import javafx .stage .Stage ;
9+
10+ public class FirstApplication extends Application {
11+
12+ @ Override
13+ public void start (Stage primaryStage ) throws Exception {
14+ Label message = new Label ("Hello World!" );
15+ message .setFont (new Font (100 ));
16+
17+ Label message2 = new Label ("Hello World2!" );
18+ message2 .setFont (new Font (100 ));
19+
20+ VBox vbox = new VBox (message , message2 );
21+
22+ primaryStage .setScene (new Scene (vbox ));
23+ primaryStage .setTitle ("JSimas" );
24+ primaryStage .show ();
25+ }
26+
27+ public static void main (String [] args ) {
28+ launch (args );
29+ }
30+
31+ }
Original file line number Diff line number Diff line change 1+ package part5javafx ;
2+
3+ import java .net .URL ;
4+ import java .util .ResourceBundle ;
5+
6+ import javafx .event .ActionEvent ;
7+ import javafx .fxml .FXML ;
8+ import javafx .fxml .Initializable ;
9+ import javafx .scene .control .PasswordField ;
10+ import javafx .scene .control .TextField ;
11+
12+ public class MyController implements Initializable {
13+
14+ @ FXML
15+ private TextField username ;
16+ @ FXML
17+ private PasswordField password ;
18+
19+ @ Override
20+ public void initialize (URL location , ResourceBundle resources ) {
21+
22+ }
23+
24+ public void okAction (ActionEvent event ) {
25+ System .out .println ("Username: " + this .username .getText () + ", Password: " + this .password .getText ());
26+ System .out .println ("OK Button Fired!" );
27+ }
28+
29+ public void cancelAction (ActionEvent event ) {
30+ this .username .setText ("" );
31+ this .password .setText ("" );
32+ System .out .println ("Cancel Button Fired!" );
33+ }
34+
35+ }
Original file line number Diff line number Diff line change 1+ package part5javafx ;
2+
3+ import javafx .application .Application ;
4+ import javafx .fxml .FXMLLoader ;
5+ import javafx .scene .Parent ;
6+ import javafx .scene .Scene ;
7+ import javafx .stage .Stage ;
8+
9+ public class SecondApplication extends Application {
10+
11+ @ Override
12+ public void start (Stage primaryStage ) throws Exception {
13+ FXMLLoader loader = new FXMLLoader (getClass ().getResource ("ihm.fxml" ));
14+ Parent root = loader .load ();
15+
16+ primaryStage .setScene (new Scene (root ));
17+ primaryStage .show ();
18+
19+ }
20+
21+ public static void main (String [] args ) {
22+ launch ();
23+ }
24+
25+ }
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+
3+ <?import javafx .geometry.*?>
4+ <?import javafx .scene.control.*?>
5+ <?import javafx .scene.layout.*?>
6+ <?import javafx .scene.paint.*?>
7+
8+ <GridPane xmlns : fx =" http://javafx.com/fxml" fx : controller =" part5javafx.MyController"
9+ hgap=" 10" vgap =" 10" >
10+
11+ <padding >
12+ <Insets bottom =" 10.0" top =" 10.0" left =" 10.0" right =" 10.0" />
13+ </padding >
14+
15+ <children >
16+ <Label text =" User name:" GridPane.columnIndex=" 0" GridPane.rowIndex=" 0"
17+ GridPane.halignment=" RIGHT" />
18+
19+ <TextField fx : id =" username" GridPane.columnIndex=" 1" GridPane.rowIndex=" 0" />
20+
21+ <Label text =" Password:" GridPane.columnIndex=" 0" GridPane.rowIndex=" 1"
22+ GridPane.halignment=" RIGHT" />
23+
24+ <PasswordField fx : id =" password" GridPane.columnIndex=" 1" GridPane.rowIndex=" 1" />
25+
26+ <HBox GridPane.columnIndex=" 0" GridPane.rowIndex=" 2"
27+ GridPane.columnSpan=" 2" alignment =" CENTER" spacing =" 10" >
28+ <children >
29+ <Button text =" Ok" onAction =" #okAction" />
30+ <Button text =" Cancel" onAction =" #cancelAction" />
31+ </children >
32+ </HBox >
33+ </children >
34+ </GridPane >
You can’t perform that action at this time.
0 commit comments