Last active
July 6, 2016 14:06
-
-
Save altayalp/cab463da757bbba052531329b899c869 to your computer and use it in GitHub Desktop.
Simple javafx ListView example
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.collections.FXCollections; | |
import javafx.collections.ObservableList; | |
import javafx.scene.Scene; | |
import javafx.scene.control.ListView; | |
import javafx.scene.layout.StackPane; | |
import javafx.stage.Stage; | |
/** | |
* Simple javafx listView example | |
* | |
* @author altayalp | |
*/ | |
public class SimpleListView extends Application { | |
public static final ObservableList<String> country = FXCollections.observableArrayList(); | |
public static void main(String[] args) { | |
launch(args); | |
} | |
@Override | |
public void start(Stage primaryStage) { | |
primaryStage.setTitle("Simple ListView Example"); | |
final ListView<String> listView = new ListView<>(country); | |
listView.setPrefSize(200, 250); | |
country.addAll( | |
"Türkiye", "Azerbaijan", "Turkestan", "Utopia", | |
"Liechtenstein", "Russian", "Italy", "Belgium", | |
"Germany", "Kuştepe" | |
); | |
listView.setItems(country); | |
StackPane root = new StackPane(); | |
root.getChildren().add(listView); | |
primaryStage.setScene(new Scene(root, 270, 235)); | |
primaryStage.show(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment