Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Rendering JRadio Buttons and JLabels in the same column

Posted on 2004-10-21
9
Medium Priority
?
527 Views
Last Modified: 2008-01-09
I am using JTable for showing one to many relationship like shown below.
Column A Column B
x              1
                2
x              3
                4
y              5
                6
y              7
                8

I am allowing user to must select one of x y. In x also he can select any combination (like x 1 or x 2). So I thought to have column A as radio buttons as x in one radio button group, y in other radio button group.
But I will be using x 1, x3 in one radio button and for empty text in column A (e.g. I am not displaying x for x 2, not displaying x for x 4) I want to use JLabel.
So column A will be mix and match of radio buttons and JLables.
How that can be achieved with given customized JTable model?
0
Comment
Question by:j74
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 37

Accepted Solution

by:
zzynx earned 1000 total points
ID: 12369541
By using your own TableCellRenderer you can show whatever you want.
But, I doubt if your solution is the right one.
I even doubt if I have understood you, well ;°)

Q: why don't you have this?

Column A Column B
x              1
                2
                3
                4
y              5
                6
               7
                8

Why do you want to repeat the x sometimes and sometimes not?
0
 

Author Comment

by:j74
ID: 12371739
I am creating parts mapping and saving to the database.
Suppose part A is mapped to the part B and Part C.
Some other user may have concern for mapping of A.
So he can create another mapping of A with part X and part Y or just part X.
So we need to store this mapping to against this user.
There may be same scenario happening for some other part say P.
So if the third user comes and for his scenario if part A and P comes, he may be shown that already Part A and Part P mapping exist. Select either of one for Part A and either of one for Part P.
This is kind of one to many relationship of part conversions and also you need to provide selection of different mapping for given part.
So for displaying the feature I am going for JTable with RadioButton and JLabel.
Part A is mapped Part B and Part C
Part A is also mapped with Part X and Part Y by other user.
Same may happen for Part P.
I thought I should provide like this:
I have 3 more columns (converting part qunatity, converted part quantity, otherfeaturedcolumn)

Part A  Part B
          Part C
PartA  Part X
          Part Y  
Part P  Part P1
          Part P2
Part P Part P3
         Part  P4  
.....
I have seen various examples for Cell Rendering, but nothing suits to me.
This has http://www.codeguru.com/java/articles/162.shtml has shown that we can
have any component in any cell but it lacks structured usage of Table Model

Let me know your thought about above mentioned scenario and sample.
Do we have other better way to show above mappings with easy business usage?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 9

Assisted Solution

by:Ovi
Ovi earned 1000 total points
ID: 12378328
If the daa maintained by your model is proper formated, the cell renderer/editor of the B column must be a trivial JPanel, which will store your custom buttons and labels. Nothing has to e changed from the default way of rendering cells as described by most of tutorials.

Please see this site for the JTable rendering examples :

http://www.objects.com.au/java/examples.do
0
 
LVL 9

Expert Comment

by:Ovi
ID: 12641823
Following the link posted by myself, will lead the owner of this question to the right answer and much more on JTable customization techniques.
0
 
LVL 37

Expert Comment

by:zzynx
ID: 12642191
My first comment was:
>> By using your own TableCellRenderer you can show whatever you want.
And in my opinion - although rather common - that deserves some points too.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question