Questions tagged [comboboxmodel]

48 questions
6
votes
2 answers

How do I print all the items within a JComboBox?

I'm wondering how to print out ALL the items within a JComboBox. I have no idea how to go about doing this. I know how to print out whatever item is selected. I just need it to where when I press a button, it prints out every option in the…
user1927670
  • 61
  • 1
  • 1
  • 2
5
votes
2 answers

How do I insert data from mysql into the combobox?

What's wrong with my code here? I'm trying to insert data from the mysql into the combobox in netbean private void btnSandoghMousePressed(java.awt.event.MouseEvent evt) { try { String query =…
5
votes
3 answers

Is there a way to prevent action listeners from firing when setSelectedItem() is called?

I have a program with multiple comboboxes, each with their own action listener. Selecting an item from any of the comboboxes will change the items in one or more of the other comboboxes. The problem I'm running into is that calling setSelectedItem()…
user259175
4
votes
1 answer

Swing MVC - refresh the content of JComboBox while already visible

I set the model of my combobox in my controller class cboCategory.setModel(new ModernDefaultComboBoxModel(model.getProductCategories())); productCategories is a List of String. ModernDefaultComboBoxModel is just model that extends…
Bnrdo
  • 5,325
  • 3
  • 35
  • 63
3
votes
6 answers

how to change combobox's data after change another combobox item selection?

I have a MVC application written in java which has a form with three comboboxes in it. year / month / day and I want to change the number of days if the selection of year and month changed. in my viewer I just define the comboboxes…
Vahid Hashemi
  • 5,182
  • 10
  • 58
  • 88
3
votes
1 answer

How to clear jComboBox after fetching value from database

can anyone please help me out with this code? enter code here i wanted to ask that how to clear the JcbSub(jComboBox) when another value is selected from the jComboBox3 in the code: 1 private void jComboBox3ActionPerformed(java.awt.event.ActionEvent…
Haider Khattak
  • 567
  • 3
  • 8
  • 32
3
votes
1 answer

Dynamically update JComboBox (NullPointerException)

I'm trying to dynamically update a JComboBox in swing application and getting a null pointer exception. class Accounts extends JPanel { JComboBox accountSelect; DefaultComboBoxModel accountSelectModel; public Accounts() { …
user1597002
3
votes
3 answers

How to insert items to a jcombobox at runtime and save it

I need to save the values in my jcombobox at the runtime. What I am trying to do is after clicking on a button, I am setting it to editable = true. Then type the value in the combobox, but it doesn't save. private void…
Sumeet Gavhale
  • 800
  • 4
  • 13
  • 39
2
votes
1 answer

Suggestion on how to debug ComboBoxModel

in my project I've several JComboBox with their custom models. Basically they are used to show values of some JTables column (therefore I decided to implement them on the relative class extending AbstractTableModel). public class MyTableModel1…
Heisenbug
  • 38,762
  • 28
  • 132
  • 190
2
votes
1 answer

Sharing same model between two JComboBoxes

I have a Person [ ] with three Persons (p1,p2,p3). Person class has two attributes name and email. I want to add all names of Person[] in one JComboBox and all emails in another JComboBox. I used the following code. Person p1 = new…
Necromancer
  • 869
  • 2
  • 9
  • 25
2
votes
0 answers

ComboBoxModel as wrapper for ListModel

I want a javax.swing.ListModel be shared among multiple javax.swing.ComboBoxModels. With the following code , when I select an item from the JComboBox,in a running program through the view, the JComboBox always shows the first item as…
Smith
  • 171
  • 2
  • 8
2
votes
3 answers

How to bind an array to JComboBox dynamically?

I binding an array to JComboBox like following: String[] arr={"ab","cd","ef"}; final JComboBox lstA = new JComboBox(arr); but I want bind array to JComboBox dynamically like following : final JComboBox lstA = new JComboBox(); void bind() { …
Samiey Mehdi
  • 9,184
  • 18
  • 49
  • 63
2
votes
1 answer

How to update JComboBox instances in Swing?

I've 3 comboboxes, upon selecting first combobox, the rest should be updated but my code doesn't seems to be working. Please help in this guys. Here is my code(since my code very long so I'll write error part only). // example code public class…
Zakir Hussain
  • 414
  • 3
  • 13
2
votes
1 answer

ComboBoxModel with Dynamic Proxied Objects

As we know the ComboBoxModel interface is used to created a class in witch we can specify how to relate a collections of objects (the model) with the combobox, basically by supplying the necessary "information" on how to retrieve items and set…
Victor
  • 3,841
  • 2
  • 37
  • 63
2
votes
1 answer

Iterate through hashmap and add items to swing jcombobox

I am working on my first Java application and I am stuck on this part where I need to populate my combobox with items from a hashmap. I am using Model View Controller approach and trying to populate the combobox from within the GUI. So, after a user…
1
2 3 4