You can reduce the number of classes by recognizing that commonality. Try out this enhancement. Remove the LargerFontAction and SmallerFontAction classes and replace them with the FontAction class. In this program, we will use a menu instead of a set of buttons to increase and decrease the font size. The menu bar contains menus , rectangular panels with menu strings inside them.
Menus contain submenus and menu items.
Only menu items have actions associated with them. Here are the instructions to build the menu for this program. Run your program and check that the menu works. Of course, selecting the menu items does not yet have any effect. Next, you need to attach actions to the menu items.