• Post Reply Bookmark Topic Watch Topic
  • New Topic

jComboBox with Image  RSS feed

 
Saakshi Dikshit
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


 
Campbell Ritchie
Sheriff
Posts: 53774
128
  • 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.
 
Rob Camick
Ranch Hand
Posts: 2754
12
  • 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.
 
Maneesh Godbole
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....
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!