Click here to Skip to main content
15,890,043 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I have a problem about jtable in java. I have a jtable with 5 columns. and two of five columns are radio button column(column 2 and column 3: click on cell of column 2 is set disable to cell of column 3 and click on cell of column 3 is disable cell of column2).
How to get current row and current column and value when click on any cell of column 2 and column 3?
I tried to use in evnent MouseClick and tableChange but unsuccessfull, on mouseClick event I can not get them, and on tableChange event sometimes I can get correct but sometimes i can not get correct.

If you know, please help me!

thank you very much!
Posted

Events are not "caught", but they are handled with event handlers which you can supply to an instance of a control class. This is explained in detail here: http://docs.oracle.com/cd/E15051_01/wlw/docs103/guide/controls/conHandlingControlCallbacks.html[^].

—SA
 
Share this answer
 
Comments
Nagy Vilmos 20-Dec-11 9:14am    
But if the event causes an exception, THEN you need to catch it. :)
Sergey Alexandrovich Kryukov 20-Dec-11 9:15am    
Sure, but this is give. And perhaps not in this stack frame. Exceptions normally be caught closer to the top of the stack frame. Exception handling is totally different aspect and is independent.

Thank you, Nagy.
--SA
There are multiple ways to get that.
The pretty simplest approach is to set a certain ActionCommand on the JRadioButton - not the smartest, but a working thingy.

Better is to customize the JRadioButton and to set some additional Data there. You can then use Event.getSource() to get the RadioButton from the SelectionListener. From there on it's your choice how to deal with it.
This is an approach that fits also dynamic GUI creations.
 
Share this answer
 
v2
Comments
Nagy Vilmos 20-Dec-11 9:14am    
Good answer. Extending the control to do what you want, who'd have thunk it? ;)
TorstenH. 20-Dec-11 9:51am    
actually - every developer should do so. I always have a library of customized components. It makes it so much easier when you generalize some and make the controls just like you need them.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900