Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more: , +
I have a project design that uses Java Swing for the GUI part of the application and it consists of multiple button classes that corresponds to each button on the main GUI. Is it useful to have so many button classes? What are the advantages of this approach? Are there alternative ways I can design this? Is it a good or a bad idea for each of them to be declared in a separate file?

What I have tried:

I only need comments on the design approach
Posted
Updated 7-Dec-16 22:32pm
v4

1 solution

If you have too many buttons on the display then the chances are that the design is going to confuse your users. Why do you need multiple button classes, why not one class that contains all the logic for a button?
 
Share this answer
 
Comments
Member 12701313- questforimprovement 8-Dec-16 11:11am    
I don't have more buttons on the GUI than required, however I do have a class for each button that `extends JButton implements ActionListener`
Richard MacCutchan 8-Dec-16 11:49am    
How many buttons, and what does each one do that cannot be done with a standard JButton?
Member 12701313- questforimprovement 8-Dec-16 12:43pm    
There are around 9 buttons, and each one of them have different ActionListener functions, except 4 of them that extends a customized Button class.
Richard MacCutchan 8-Dec-16 12:58pm    
Having different ActionListeners does not require new classes.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900