In this video tutorial, I show you how to create combo boxes in Java Swing. This tutorial is also a review of everything I’ve previously gone over.
I review how to create the frame and panel. How to add buttons with event listeners. I also review JOptionPane. I’m slowing down a bit so that I’m sure you understand everything that proceeded this tutorial.
All of the code follows the video below. Leave any questions below.
If you like videos like this share it [nttfblike]
Code from the Video
hi derek thanks a lot for the videos, i have a question, how can we add listeneres on combobox, so that when a particular item is selected on the combo box we wanna do something.
You’re very welcome 🙂 You want to do something like this
myComboBox.addActionListener (new ActionListener () {public void actionPerformed(ActionEvent e) {
doSomething();
}
});
Derek,
If they gave away Nobel Prizes for education I think that I would nominate you. Thank you for all of you work.
I hesitate to ask this because it is a bit of work but I navigate you site by the every lesson page then to the Java tutorials. It would be nice if the links had a description next to them on the topics covered. i.e. lesson 20 Basics of Swing class. Frames, JPannel, buttons and text fields. Or something like that. often finding myself going and looking for a earlier video and having to hunt through them till I find the one I’m looking for. Not a big deal as I really don’t want to be looking a gift horse in the mouth but it would be useful.
Thank you for the nice compliment 🙂 Yes I have been working to make it easier to find information on my site. In the last few tutorials I have actually done exactly what you said, but I need to do that with my main Java video tutorial. I’ll try to get that done this week.
Just listened to your Java#24 YouTube session today. It appeared to cut off long before you intended(?).
I’ve been following your sessions and feel sort of “robbed”. I’ll go forward, but would like to know if there was more to the lesson or was it a cliffhanger [sort of like “who killed JR].
That is really odd? I think the file may have been messed up on YouTubes servers. I’ll see if there is any way to fix that. I do have the code below to help either way. Sorry about that.
I am facing the same issue. It doesn’t play beyond 2:07 mins. 🙁
Thanks Derek for the great videos. You have made it easy to learn Java.
Sorry, but YouTube won’t let me update it 🙁
Could you perhaps put a link to the correct website in the comments section of YouTube? This is a topic we’re covering in class as well. Love your videos by the way. They’re a life saver.
Thank you 🙂 I fixed the link
Hi Derek.
Great and easy videos so far. Keep it going.
I am having the same problem reported as others, the video stops at 2:02min and it doesn’t go any further, it doesn’t load. Tried different browsers and deleting cache, history etc. but still nothing
Hi, Sorry, but it seems like YouTube messed up that video and won’t let me replace it. The code and comments will have to fill in. Sorry
Hi Derek,
Regards and thanks for your great videos. How can one add key/value pairs to a combobox , so that the combobox shows the values but you can get the key assigned to that value ?
Hi Ben, Take a look here https://docs.oracle.com/javase/7/docs/api/java/util/Map.html