• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How do I display two columns in my jcombobox?

 
Phillip Ankerson
Greenhorn
Posts: 27
Java MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • 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:

 
Rob Spoor
Sheriff
Pie
Posts: 20610
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • 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
Java MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure sorry about that!
 
Rob Camick
Ranch Hand
Posts: 2613
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here are a few different ways:

 
Phillip Ankerson
Greenhorn
Posts: 27
Java MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • 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
Ranch Hand
Posts: 2613
9
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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
Java MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, it's a hassle for sure. Much too thick. I'll probably start from scratch.
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • 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.
 
Maneesh Godbole
Saloon Keeper
Posts: 11096
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JComboBox? Two Columns? Hmmm.
I think using a JTable would be easier.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic