Forums Register Login

how to auto update jcombobox?

+Pie Number of slices to send: Send
i apologies to making it confused...
i have removed all the unrelated code from my main class, here is formatted main class.
WelcomeScreen1.java
+Pie Number of slices to send: Send
I can put all this together now, and, *very* seriously a lot of it is garbage, and should be thrown out.

hide/show? that type of coding disappeared in the last century - if you must toggle between screens,
use a CardLayout.

I've posted several times to get rid of the search function, and to add it later when you get the original
problem working.

So, unless you're prepared to post an opening screen with a textfield/comboBox/button, where the
comboBox is loaded from a database (include the db code, I can easily simulate an arraylist for it),
and the button, when clicked, will add whatever is in the textfield to the database, then subsequently
refreshing the comboBox with the newly added data, I can do no more - someone else may come along
and assist.
+Pie Number of slices to send: Send
 


hide/show? that type of coding disappeared in the last century - if you must toggle between screens,
use a CardLayout.


i was not aware to that, i will replace that code, with cardlayout.


I've posted several times to get rid of the search function, and to add it later when you get the original
problem working.


okay, below is the display and display1 class, here combobox is added from database.

Display1.java


Display.java


rest of the classes, loadStudent, saveStudent, Db are same.
+Pie Number of slices to send: Send
it all works fine here.
I wrapped all ther classes together, so they could 'see' the simulated database.
you just need to put back the db code and it should work the same way.

+Pie Number of slices to send: Send
michael,
with arraylist code is works fine here, but i just added the db part, and again the same problem, nothing i did i only added the db part, i mean just uncomment that, and commented the arraylist.
again i have to restart my application to see the last inserted value, not getting updated.
here is the code with db:-

+Pie Number of slices to send: Send
you'll have to put in a bunch of System.out.println's (one at a time) starting at
line 49 d1.update()
to see where the program goes i.e. if the message is printed, move the println
to the next section. Eventually you should find where the message is not printed
so you can check that bit of code.

the code looks OK.
the only db stuff I've done was ages ago, in another language, where you had to
close the connection. That may be the same in java, don't know.
+Pie Number of slices to send: Send
instead of loading the resultset into combobox, if i load the arraylist, all works fine.
values are going into db.
but when i load resultset, the problem comes.
+Pie Number of slices to send: Send
well, i tried something, and it's worked, only one problem is in this approach.
what i did is:
in the nameValues(), instead of returning resultset, i added resultset to arraylist, and then i am returning arraylist, it's worked, but values in combobox are coming multiple times.
i mean the value which i entered last in coming once, but the earlier ones getting increased, might be some problem in loop..?
here is the method:


calling in the same way..
+Pie Number of slices to send: Send
everything looks OK, and it must work OK, because it loads the newly saved data
if you close the app then reopen it.

the problem is when update() is called, so you'll just have to go through those steps
I posted earlier. you could also printout the resultSet size to see if there's any difference
between when the app opens, and when something is saved.
+Pie Number of slices to send: Send
finally done......
the problem was here:


thank you thank you thank you very much michael..
your help is very much appreciable..
Thank you
+Pie Number of slices to send: Send
> finally done.....

well done, I knew you'd get there in the end - mostly just a matter of putting things together in the right order.
+Pie Number of slices to send: Send
 


well done, I knew you'd get there in the end - mostly just a matter of putting things together in the right order.


yes, and also because of your help..
so thanks agaiin michael..
You didn't tell me he was so big. Unlike this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 12938 times.
Similar Threads
Comment on GUI..
List box appearing over JMenuBar dropdown
Problem in combo box
Help Displaying on panel!!!!
how to retrive a value from a check box on one page to another page containing a com
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 03:01:16.