How to implement different actions for different Buttons in JTable?
Hi all,
I'm working in JTable having 1 column of buttons. I have implemented renderer and editor for Button.class.... My problem is , i want to assign different functions to different buttons, but using ActionListener in Editor, same action is performed on every button click..
I'm stuck....Plz help..........
Tapsi.
[343 byte] By [
Tapsi07a] at [2007-11-27 10:22:02]

# 1
hi
you just need to look for current row, and then decide what action you want, then you can invoke different function from your actionPerformed
if it does not helps, then provide
Short, Self Contained, Compilable and Executable, Example
Program (SSCCE) that demonstrates the incorrect behaviour.
Don't forget to use the Code Formatting Tags
so the posted code retains its original formatting.
regards
Aniruddha
# 2
Thanks Aniruddha for replying...
But can you please elaborate(i'm new to Java(started working 1 month back))... the editor in this case is for JButton class objects and is a seperate class that implemets actionlistener....and there's another class that extends JTables.....
so for every button push the editor class is activated .... how can I find the row?
Tapsi.
# 3
Give a try to this : Implement ActionListener
from your editor class. Override the actionPerformed
method. From this method get the caption of the buttons(if they are different) and provide functionality accordingly.
max25a at 2007-7-28 17:13:33 >

# 4
well, you can play with the refference object of the table class, or you can store that in some global variable(application) ....
this is why i asked you for a demo code.. so that for any one it would be wasy to solve your problem.
regards
Aniruddha