SHOW:
|
|
- or go back to the newest paste.
1 | import javafx.application.Application; | |
2 | import javafx.event.ActionEvent; | |
3 | import javafx.event.EventHandler; | |
4 | import javafx.scene.Scene; | |
5 | import javafx.scene.control.Button; | |
6 | import javafx.scene.control.ComboBox; | |
7 | import javafx.scene.control.TextField; | |
8 | import javafx.scene.layout.VBox; | |
9 | import javafx.stage.Stage; | |
10 | ||
11 | public class test extends Application { | |
12 | ||
13 | public static void main(String[] args) { | |
14 | launch(args); | |
15 | } | |
16 | ||
17 | @Override | |
18 | public void start(Stage stage) { | |
19 | ||
20 | stage.setTitle("Table View Sample"); | |
21 | stage.setWidth(450); | |
22 | stage.setHeight(550); | |
23 | ||
24 | VBox hbox = new VBox(10); | |
25 | ||
26 | ComboBox<String> box = new ComboBox<>(); | |
27 | box.getItems().add("test"); | |
28 | box.setEditable(true); | |
29 | box.getSelectionModel().selectFirst(); | |
30 | ||
31 | ||
32 | TextField textfield = new TextField(); | |
33 | ||
34 | Button defaultButton = new Button("press"); | |
35 | defaultButton.setOnAction(new EventHandler<ActionEvent>() { | |
36 | @Override | |
37 | public void handle(ActionEvent arg0) { | |
38 | System.out.println("button pressed!"); | |
39 | } | |
40 | }); | |
41 | defaultButton.setDefaultButton(true); | |
42 | ||
43 | // Comment out this line for the second test | |
44 | - | box.onActionProperty().bind(defaultButton.onActionProperty()); |
44 | + | // box.onActionProperty().bind(defaultButton.onActionProperty()); |
45 | ||
46 | hbox.getChildren().addAll(box, textfield,defaultButton); | |
47 | Scene scene = new Scene(hbox); | |
48 | stage.setScene(scene); | |
49 | stage.show(); | |
50 | } | |
51 | ||
52 | } |