Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Refresh JComboBox

 
Sandeep Swaminathan
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's a combo box which displays items from the database and I delete it. I want to REFRESH it then and there.

I tried
jcbCombo.updateUI();
jcbCombo.repaint();
jcbCombo.revalidate();

Didnt work! What to do?

 
Maneesh Godbole
Saloon Keeper
Posts: 11021
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you deleting the data? Can you post your relevant code?
 
Rob Spoor
Sheriff
Pie
Posts: 20511
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JComboBox (and JList, JTree and JTable) works with a model that contains the actual data. You'll need to remove from that and add again.
 
Sandeep Swaminathan
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The code below is used to display the names of XSMeter in a combobox from the back-end.



After deletion I want to refresh the combobox so that the deleted file is removed from the combobox. Commented lines are what I thought would work but didnt! I have no clue how to go about!



 
Maneesh Godbole
Saloon Keeper
Posts: 11021
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your code just fires the delete query on the DB, but does not delete from JComboBox
 
Sandeep Swaminathan
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh oh! Tat was silly of me! Gotcha! Thanks for the info! I didn't notice it at all :p
 
Maneesh Godbole
Saloon Keeper
Posts: 11021
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are welcome.
Don't worry about it. Happens to everyone
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic