package hellofx; import javafx.application.Application; import javafx.collections.FXCollections; import javafx.geometry.Pos; import javafx.scene.Scene; import javafx.scene.control.ChoiceBox; import javafx.scene.control.Label; import javafx.scene.layout.VBox; import javafx.scene.text.Text; import javafx.stage.Stage; public class GUI019 extends Application { Text t = new Text(); @SuppressWarnings({ "unchecked", "rawtypes" }) @Override public void start(Stage stg1) throws Exception { VBox pn = new VBox(); pn.setAlignment(Pos.CENTER); pn.setSpacing(20); pn.getChildren().add(new Label("Pick your fav K-pop star!")); ChoiceBox cb = new ChoiceBox(FXCollections.observableArrayList("Joo Ko-Wee", "Park Bo-Wow")); cb.setOnAction(e -> { t.setText("사랑해, " + ((ChoiceBox) e.getSource()).getValue() + " Oppa!"); }); pn.getChildren().add(cb); pn.getChildren().add(t); Scene scn = new Scene(pn, 180, 150); stg1.setScene(scn); stg1.setResizable(false); stg1.show(); } public static void main(String[] args) { Application.launch(args); } }