Created
July 12, 2015 02:09
-
-
Save ahn94/3a98d4111812fff44fc8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javafx.application.Application; | |
import javafx.application.Platform; | |
import javafx.geometry.Insets; | |
import javafx.scene.Scene; | |
import javafx.scene.control.*; | |
import javafx.scene.layout.*; | |
import javafx.stage.Stage; | |
public class Main extends Application { | |
Stage window; | |
Scene scene; | |
Button button; | |
public static void main(String[] args) { | |
launch(args); | |
} | |
@Override | |
public void start(Stage primaryStage) { | |
window = primaryStage; | |
window.setTitle("Austin"); | |
button = new Button("Click Me"); | |
ChoiceBox<String> choiceBox = new ChoiceBox<>(); | |
choiceBox.getItems().addAll("Apples", "Bananas", "Bacon", "Ham", "Meatballs"); | |
choiceBox.setValue("Apples"); | |
button.setOnAction(event -> getChoice(choiceBox)); | |
//Layout | |
VBox layout = new VBox(10); | |
layout.setPadding(new Insets(20, 20, 20, 20)); | |
layout.getChildren().addAll(choiceBox, button); | |
Scene scene = new Scene(layout, 300, 250); | |
window.setScene(scene); | |
window.show(); | |
} | |
private void getChoice(ChoiceBox<String> choiceBox){ | |
String food = choiceBox.getValue(); | |
System.out.println("Choice is: " + food); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment