getSource « Event « Java Swing Q&A





1. use EventObject.getSource in Actionlistener    stackoverflow.com

I am refactoring some code for an assignment - currently the view has lots of buttons and menus and one action listener which decides what to do by using event.getSource(). From ...

2. Java-Swing: Change getSource() in ActionListener    stackoverflow.com

I have a class that contains a JButton. This can't be changed. The problem is this: The actionListener calls getSource() and gets the JButton, not the container class. Can I change what getSource ...

4. getSource() in actionPerformed    coderanch.com

I'm having a problem where i've got 2 buttons, I've added actionListeners to both with build.addActionListener(this); prebuilt.addActionListener(this); and I'm using public void actionPerformed (ActionEvent event) { System.out.println("click"); if (event.getSource() == build) { System.out.println("build clicked"); } if (event.getSource() == prebuilt) { System.out.println("Prebuilt clicked"); } } to differentiate between the two buttons but neither of them do what they are supposed to. If ...