my dog learned polymorphism*
The moose likes Swing / AWT / SWT and the fly likes JPanel Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JPanel" Watch "JPanel" New topic
Author

JPanel

ranjeeth ravindran
Greenhorn

Joined: Feb 13, 2010
Posts: 10

Can any one help me.

I have a JFrame and 6 Pannels inside it,my first pannel consists of a combobox whitch fetches data from the database and displays into it
,but i have a problem whenever i add new data to the database at runtime it gets updated in the database but doesnt updates the Combobox.

How to solve this problem. can anyone help me.
I have tried revalidate,validate but its not working.
ranjeeth ravindran
Greenhorn

Joined: Feb 13, 2010
Posts: 10

ranjeeth ravindran wrote:Can any one help me.

I have a JFrame and 6 Pannels inside it,my first pannel consists of a combobox whitch fetches data from the database and displays into it
,but i have a problem whenever i add new data to the database at runtime it gets updated in the database but doesnt updates the Combobox.

How to solve this problem. can anyone help me.
I have tried revalidate,validate but its not working.
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2157
    
    7
You need to query the database to get the new values and then you need to recreate the ComboBoxModel and use

comboBox.setModel(...);

to update the combo box.
ranjeeth ravindran
Greenhorn

Joined: Feb 13, 2010
Posts: 10

can you help me with the paramaters that i should enter in setModel()

I am using resultset to retrieve the values from the database.


can you help me with one more doubt.

My frame consists of 6 pannels ,i have a button in pannel one and i want to close the parent frame on click of the button.
how will it be done.

please help
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2157
    
    7
Read read a value from the ResultSet and add it to the model using the addElement() method.
ranjeeth ravindran
Greenhorn

Joined: Feb 13, 2010
Posts: 10

can you please send me an example code.
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> can you please send me an example code.

you already have it - just about the same as when you initially load the comboBox,
but using a model
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JPanel
 
Similar Threads
how to populate value in combo box
How to populate second combo box on the basis of first combo
how to display data from db in textbox according to data selected in combobox in jsp
refresh the contents of combobox
combobox