From the course: Learn Java with Swing

Unlock the full course today

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

Challenge

Challenge - Java Tutorial

From the course: Learn Java with Swing

Start my 1-month free trial

Challenge

- [Instructor] Welcome to your next challenge. In this challenge, we're going to actually add some logic to our grocery list application from earlier. Earlier, we created a graphical user interface for a grocery list application that allowed us to add items to a list. Now the interface included labels and a text area, as well as three buttons that said Add, Print, and Clear. In our prior challenge, we just added the GUI, we didn't actually add any logic behind the buttons. So, this time, you're going to add event listeners to each of the buttons and then add code to handle the buttons, so when the user types in into the text box and clicks Add, it should add whatever that item is into your list, which shows up in your text area. If the user clicks on the Print button, it'll print out what's in the text area to the console. Finally, if the user clicks the Clear button, it will clear the text area. Here is a picture of the graphical user interface. You can see I used the sample form…

Contents