Hi ,
I have created a jframe which contains a combobox.
I want the combobox to be populated with data from a database as soon as the window/Jframe is displayed.
How to do this.
Any help is welcome.
Regards,
Praveen Shinde
Hi Ritchie,
I am familar with database access.
My main problem is to display the data in the combo box as soon as the Jframe is opened.
regards,
Praveen
1) Subclass JComboBox
2) Provide a method called loadData which will connect to the DB, pull out required data and insert into the JComboBox. Make sure this happens in a separate thread .
3) Add your subclassed combo box instance to the frame.
4) Overide setVisible() in your frame instance
5) Invoke super.setVisible() and combo.loadData() in your overridden setVisible()
Hello Maneesh,
I created a frame with 6 panel(without using drag n drop facility of Netbeans). I still cant see all the panels. I even tried adding a scrollbar.
Please help
Thanks
Praveen
Maneesh Godbole wrote:1) Subclass JComboBox
2) Provide a method called loadData which will connect to the DB, pull out required data and insert into the JComboBox. Make sure this happens in a separate thread .
3) Add your subclassed combo box instance to the frame.
4) Overide setVisible() in your frame instance
5) Invoke super.setVisible() and combo.loadData() in your overridden setVisible()
And yes. In future please UseAMeaningfulSubjectLine
I'd prefer loading the data via a ComboBoxModel implementation, instead of tying a subclass of JComboBox directly (or indirectly) to a datasource via a custom loadData() method.
Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
The government thinks you are too stupid to make your own lightbulb choices. But this tiny ad thinks you are smart:
Gift giving made easy with the permaculture playing cards