java - Refactoring multiple actionListeners -


I am currently working on some Java code, which has many appellantists, including each JButton ) And approximately 60 buttons, all of which are defined as anonymous internal organs in the JButton.addActionListener method. I was thinking to think that it seems to be very crappy as a way to refocus the code to make the sensor. I thought that maybe the audience can be taken to a different class which essentially puts the load of stable methods to return to each listener. This would mean that something like code addActionListener (GetActionListener.addActionListener ()) will appear. Although this will make it a nipper, I think that this is not really a great solution. I thought that the listener has a stable final map with the KV couple in the name of the listener as well. Yet still it does not seem like a very beautiful solution. I was wondering if anyone had any ideas? I should also say that all caretakers are very different.

I say that ActionListener If you do this then it becomes non-reusable, instead wrap your work in the javax.swing.Action category. So that you can take action wherever you want. For example, you can use a single action shortcut for a copy operation and the same action for the copy button in the toolbar. Actually this idea is not to work directly with GUI elements.

Now your question is coming. I call a repository of tasks, make ActionRepsoitory get the action with a public method. Each of your actions will be identified by string constants that you use to retrieve the action from the repository. Typically this will be the actionCommand for string element, how to manage actions in the ActionRepository, which is completely dependent on a hashpe or whatever.

This is how it is most proffesional code, AFAIK.


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -