Should all the elements of GUI be private. i.e should the panels which are created to hold buttons, combo boxes also be made private. But only buttons and combo boxes have meaning in the assignment(i.e invokes business methods). So can I make only buttons and comboboxes private and the rest(panels holding the buttons) with default access specifier. please clarify. Thanks.
posted 14 years ago
I wanted to clarify whether the following assumption is correct 1) only comboboxes and buttons should be instance variables of the GUI class and all other components like panels, tabbed pane which hold them should be local variables either in the constructor or in the methods, which create the GUI.
Well, it is your choice how you do it. I am on the mind set that the GUI is public, everyone sees it, users I mean. And its purpose is to display things. However, it's purpose is not to know what it is displaying, so to speak. That is why all my objects on the GUI are public. Others will argue differently, and their arguments are not wrong either. You could have assessor methods to get to private GUI objects any way you want. Both work, and are at the programmers discrection. I have seen both get 20/20 on the GUI part of the exam. Mark