File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Refresh JComboBox Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Refresh JComboBox" Watch "Refresh JComboBox" New topic
Author

Refresh JComboBox

Sandeep Swaminathan
Ranch Hand

Joined: Apr 23, 2008
Posts: 52
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?


Music is all around us. All you have to do is just LISTEN to it,
Sandeep Swaminathan
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 9990
    
    7

How are you deleting the data? Can you post your relevant code?


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19543
    
  16

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Sandeep Swaminathan
Ranch Hand

Joined: Apr 23, 2008
Posts: 52
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

Joined: Jul 26, 2007
Posts: 9990
    
    7

Your code just fires the delete query on the DB, but does not delete from JComboBox
Sandeep Swaminathan
Ranch Hand

Joined: Apr 23, 2008
Posts: 52
Oh oh! Tat was silly of me! Gotcha! Thanks for the info! I didn't notice it at all :p
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 9990
    
    7

You are welcome.
Don't worry about it. Happens to everyone
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Refresh JComboBox
 
Similar Threads
Eclipse error when moved from 3.0 to 3.1
JARS are visible threrough RAD 7.0
Refresh page programatically
Upload attachment to QC [Quality Center] using java
How to identify when refresh button of browser or f5 is pressed