JavaRanch » Java Forums »
Java »
Swing / AWT / SWT
| Author |
How do I display two columns in my jcombobox?
|
Phillip Ankerson
Greenhorn
Joined: Aug 10, 2011
Posts: 27
|
|
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:
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
Welcome to the Ranch!
Could you please UseCodeTags next time? I've added them for you this time.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Phillip Ankerson
Greenhorn
Joined: Aug 10, 2011
Posts: 27
|
|
|
Sure sorry about that!
|
 |
Rob Camick
Ranch Hand
Joined: Jun 13, 2009
Posts: 1787
|
|
Here are a few different ways:
|
 |
Phillip Ankerson
Greenhorn
Joined: Aug 10, 2011
Posts: 27
|
|
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
Ranch Hand
Joined: Jun 13, 2009
Posts: 1787
|
|
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
Joined: Aug 10, 2011
Posts: 27
|
|
Yes, it's a hassle for sure. Much too thick. I'll probably start from scratch.
|
 |
Darryl Burke
Bartender
Joined: May 03, 2008
Posts: 4163
|
|
|
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.
|
luck, db
There are no new questions, but there may be new answers.
|
 |
Maneesh Godbole
Saloon Keeper
Joined: Jul 26, 2007
Posts: 8431
|
|
JComboBox? Two Columns? Hmmm.
I think using a JTable would be easier.
|
[Donate a pint, save a life!] [How to ask questions] [Onff-turn it on!]
|
 |
 |
|
|
subject: How do I display two columns in my jcombobox?
|
|
|
|