first of all, I am sorry if I post it in the wrong sub-forum...but I guess this is a GUI problem..?I am not sure :<
the code below will probably explain the problem I got, but my goal is to have 2(or more) exactly same button in a Panel and have different effect when I clicked it. The only difference between those buttons will be location on the screen, is there anyway I can extract that information AFTER I get an unknown action event from 1 of them?
edit : The only thing I need to keep constant is the text on the button, the color and they need to use the same action listener, all other property is changable, if this info helps.
for your information,I know I could 'solve' the problem by assigning unique action listener to each button to solve the problem, but that method will not fit into all my other code, unless I am willing to re-do 5000 lines of code...
begging for a solution
b = new JButton("Button"); b.addActionListener(this); add(b); b = new JButton("Button"); b.addActionListener(this); add(b);public void actionPerformed(ActionEvent e) { JButton s = (JButton)e.getSource(); //This line here will tell me I got a event from "Button", which //I have no way to tell which button it is actually refering to }