File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Refresh JComboBox

 
Sandeep Swaminathan
Ranch Hand
Posts: 52
  • 0
  • 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: 10971
11
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • 0
  • 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: 20369
44
Chrome Eclipse IDE Java Windows
  • 0
  • 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
  • 0
  • 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: 10971
11
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • 0
  • 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
  • 0
  • 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: 10971
11
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are welcome.
Don't worry about it. Happens to everyone
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic