0
I have a project in netbeans that uses Java Swing for the interface. I have some data in MYSQL that I would like to show you as soon as the window is created.
Anyway, how can I place items in a Jcombobox dynamically in java?
0
I have a project in netbeans that uses Java Swing for the interface. I have some data in MYSQL that I would like to show you as soon as the window is created.
Anyway, how can I place items in a Jcombobox dynamically in java?
4
Since you have no further details, I’ll give you the most general answer possible.
Just use the method addItem
combobox.addItem("Item 1");
combobox.addItem("Item 2");
combobox.addItem("Item 3");
-1
1) first you have to make the connection this can be done in Pure JDBC or JPA
2) You create a DAO based on one example
3) In Your Jframe class you will do the following
public class SeuFrame(){
public SeuFrame(){
carregarCombo();
}
public void carregarCombo(){
SeuDAO dao = new SeuDAO();
List<SuaClasse> list = dao.lista();
for(SuaClasse item: list){
seuCombobox.addItem(item);
}
}
}
Honestly your answer is still based on links. This code does not answer the question, besides you add things that were not requested.
Sorry there, humility. I’m coming now and I’m still getting the hang of it
@Demyscota is quiet and no one is scolding, these are just guidelines, so please read Help: http://answall.com/help/answering and welcome! ;D
Browser other questions tagged java swing combobox
You are not signed in. Login or sign up in order to post.
https://www.youtube.com/watch?v=CCdgl1dlfmY Check out this video lesson that will help you, In this video you will learn how to connect with the bank, create the crud and popular in Jcombobox, and not only jcombobox.addItem(). How likely you should have seen
– Demys Cota
Describing the general problem you will get only a general answer. Example: "How to build a house?" , "Use blocks and cement, build solid walls". Instead ask something specific and responsive in a useful way: "How to lift a wall using this type of block with such a slope and such height safely?" , answer: "Position the blocks in such format, run this block placement algorithm, do not use this tool because there is such a risk, here is an example running from a wall ready for you to see how it does [link]". See? Too many wide questions don’t help.
– Sorack