From the course: Learning JavaFX GUI Development

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Provide a ListView for user selections

Provide a ListView for user selections

From the course: Learning JavaFX GUI Development

Start my 1-month free trial

Provide a ListView for user selections

- [Voiceover] Another helpful tool in JavaFX is the ability to have a ListView. This node allows us to show the user a list of options to select from. We can set the list to allow one, or multiple, selections, depending on our business rules. ListView is similar to an array list in Java. A ListView can be displayed either horizontally or vertically. It uses the JavaFX collections library to create an observable array list. My next example has a list of Pennsylvania colleges and universities. The user can select a college or university. When they choose an item from the list, we will display a confirmation message. I have a template program created, we just need to add the ListView components. Let's switch over to NetBeans. Here's my template program. I have a label at the top that will say select a college or university. I added a title to the page that says PA colleges and universities. I have an observable list created, but right now it won't show on the screen because I didn't add…

Contents