Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javafx.application.Application;
- import javafx.event.ActionEvent;
- import javafx.event.EventHandler;
- import javafx.scene.Scene;
- import javafx.scene.control.Button;
- import javafx.scene.control.ComboBox;
- import javafx.scene.control.TextField;
- import javafx.scene.layout.VBox;
- import javafx.stage.Stage;
- public class test extends Application {
- public static void main(String[] args) {
- launch(args);
- }
- @Override
- public void start(Stage stage) {
- stage.setTitle("Table View Sample");
- stage.setWidth(450);
- stage.setHeight(550);
- VBox hbox = new VBox(10);
- ComboBox<String> box = new ComboBox<>();
- box.getItems().add("test");
- box.setEditable(true);
- box.getSelectionModel().selectFirst();
- TextField textfield = new TextField();
- Button defaultButton = new Button("press");
- defaultButton.setOnAction(new EventHandler<ActionEvent>() {
- @Override
- public void handle(ActionEvent arg0) {
- System.out.println("button pressed!");
- }
- });
- defaultButton.setDefaultButton(true);
- // Comment out this line for the second test
- // box.onActionProperty().bind(defaultButton.onActionProperty());
- hbox.getChildren().addAll(box, textfield,defaultButton);
- Scene scene = new Scene(hbox);
- stage.setScene(scene);
- stage.show();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement