Advertisement
Oslapas

Untitled

Feb 10th, 2020
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.63 KB | None | 0 0
  1.  
  2.  
  3. import javafx.application.Application;
  4. import javafx.beans.value.ChangeListener;
  5. import javafx.beans.value.ObservableValue;
  6. import javafx.event.ActionEvent;
  7. import javafx.event.EventHandler;
  8. import javafx.scene.Scene;
  9. import javafx.scene.control.Button;
  10. import javafx.scene.control.Label;
  11. import javafx.scene.control.TextField;
  12. import javafx.scene.layout.GridPane;
  13. import javafx.scene.layout.HBox;
  14. import javafx.scene.layout.StackPane;
  15. import javafx.stage.Stage;
  16.  
  17. /**
  18.  *
  19.  * @author reegan
  20.  */
  21. public class GridPaneStackOverFlow extends Application {
  22.  
  23.     @Override
  24.     public void start(Stage primaryStage) {
  25.  
  26.         GridPane gp = new GridPane();
  27.         gp.add(createNode("Stack"), 0, 0);
  28.         gp.add(createNode("Over"),0,1);
  29.         gp.add(createNode("Flow"), 0, 2);
  30.         StackPane root = new StackPane();
  31.         root.getChildren().add(gp);
  32.  
  33.         Scene scene = new Scene(root, 300, 250);
  34.  
  35.         primaryStage.setTitle("Hello World!");
  36.         primaryStage.setScene(scene);
  37.         primaryStage.show();
  38.     }
  39.  
  40.  
  41.     public static void main(String[] args) {
  42.         launch(args);
  43.     }
  44.  
  45.     public HBox createNode(String label) {
  46.         HBox box = new HBox(20);
  47.         final Label l = new Label(label);
  48.         TextField field = new TextField();
  49.         field.textProperty().addListener(new ChangeListener<String>() {
  50.             @Override
  51.             public void changed(ObservableValue<? extends String> ov, String t, String t1) {
  52.                 System.out.println( l.getText()+ " : " +t);
  53.             }
  54.         });
  55.         box.getChildren().addAll(l,field);
  56.         return box;
  57.  
  58.     }
  59.  
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement