This week's book giveaway is in the Android forum.
We're giving away four copies of Learning Java by Building Android Games and have Jean-Marcel Belmont on-line!
See this thread for details.
Win a copy of Learning Java by Building Android Games this week in the Android forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

jComboBox with Image  RSS feed

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sir my database contains path of images that I want my jComboBox to diaplay. I have written the following code but it does not work for comboBox but works fine when I display image on jLabel etc. Kindly tell me how should I go about this


 
Marshal
Posts: 60748
189
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Always use code tags; I added them for you and you can see it looks a lot better, and you have lost the ugly effect, too.
Please explain what happens; we need to know more than you have told us. What actually appears on the combo box? A combo box is intended to display text, principally.
 
Rancher
Posts: 2958
20
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to use a custom renderer to display the image. Read the JCombBox API and you will find a link to the Swing tutorial on "How to Use Combo Boxes" which explain what a renderer is and give you an example of a renderer to display an image.
 
Saakshi Dikshit
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sir nothing is displayed in the Combo Box when the above code is run.
 
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Saakshi Dikshit wrote:Sir nothing is displayed in the Combo Box when the above code is run.


Did you check out the How to use ... section which Rob pointed out to you? If yes, post your SSCCE code which uses a renderer
 
Saakshi Dikshit
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I removed the jLabel line from between and then it worked out fine....
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!