• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

How do I display two columns in my jcombobox?

 
Greenhorn
Posts: 27
Netbeans IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Windows XP
Netbeans IDE v7
Java newbie (to state the obvious)

This is a Java GUI app. It is working great after much trial, effort, learning, and some great tips from this forum! Now I want the combobox to display two columns from the database instead of just one. I need the combobox to allow selecting only certain rows, depending on the value of the second column.

For example, the list displays:



I want all to display but you can only select from rows that have Used_Flag = 1.

I have a custom renderer for the combobox:



Here is my entity class Pacor:

 
Sheriff
Posts: 22647
126
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch!

Could you please UseCodeTags next time? I've added them for you this time.
 
Phillip Ankerson
Greenhorn
Posts: 27
Netbeans IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sure sorry about that!
 
Rancher
Posts: 3262
30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here are a few different ways:

 
Phillip Ankerson
Greenhorn
Posts: 27
Netbeans IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, I read that in another forum but am unsure how to implement that in my Project.
All of the code for the combobox was generated by Netbeans and I am not sure where I can insert custom code to accomplish this.
One of my goals is to re-code my project manually (like you've done); but I'd like to get it done in the IDE first. Here is the main class:



A lot of that code is not editable so changes have to be made in the GUI property boxes, but I'm trying to figure that part out!

Thank you!
 
Rob Camick
Rancher
Posts: 3262
30
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have no idea how to do this in an IDE.

I would rather spend my time learnting Java instead of learning the IDE.
 
Phillip Ankerson
Greenhorn
Posts: 27
Netbeans IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, it's a hassle for sure. Much too thick. I'll probably start from scratch.
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good idea. To repeat once again what I've said many many times before, a visual designer is not a beginners' tool. To be able to use its features, you need to already know the intricacies of Swing coding.
 
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
JComboBox? Two Columns? Hmmm.
I think using a JTable would be easier.
 
Everyone is a villain in someone else's story. Especially this devious tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic