• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

combobox

 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Marshal
Posts: 79941
396
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I presume you are familiar with database access?
 
praveen shinde
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
praveen shinde
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi maneesh,
Thanks for the help.
I will try out your suggestions.
yes I will use more relevant headlines in future.
regards,
Praveen
 
praveen shinde
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
is this just a continuation of your other thread?

https://coderanch.com/t/506199/GUI/java/panels-not-displayed-fullly-Jframe

if so, instead of encouraging everyone to play '20-guesses', why don't you post your code,
so we can see what you're doing (incorrectly).
 
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
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
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic