anonymous « Event « Java Swing Q&A





1. Java Swing: How to remove an anonymous ActionListener from a component    stackoverflow.com

I created an array of JButtons with anonymous ActionListeners and under certain conditions I want to remove all the ActionListeners, but the .removeActionListeners method requires an ActionListener as an argument. How would ...

2. Java: where should I put anonymous listener logic code?    stackoverflow.com

we had a debate at work about what is the best practice for using listeners in java: whether listener logic should stay in the anonymous class, or it should be in ...

3. Java Swing anonymous actions    stackoverflow.com

Is it ok to set actions like in the code sample below? Are there any possible garbage collection problems that might be caused by this? And if not what would be ...

4. Swing component listening to itself vs inner classes    stackoverflow.com

I just got some bad feedback on a uni project and need some impartial clarification; Can anyone explain when I should use (anonymous) inner listener classes vs components that listen to themselves? ...

5. Calling a method inside an Anonymous ActionListener that throws and exception, without using try/catch    stackoverflow.com

public class Test {
public void buildGUI()
{
    JFrame frame = new JFrame();
    JButton send = new JButton("Send");
    send.addActionListener(new ActionListener()
    {
 ...

7. Anonymous Vs. Inner Vs. Independent Class for Event Listeners    coderanch.com

Hello, This is a question regarding appropriate coding approach. For listeners, we have the following approach: - Anonymous Class Vs. Inner Class - Inner Class Vs. Independent, Stand-alone Class My understanding is that for listeners performing minimal functionality, an anonymous class will do just fine. For all the rest, I prefer to use inner classes. During the code review, suggestion was ...