• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

access specifiers for GUI elements

 
Saraswathy Krishnamoorth
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Saraswathy Krishnamoorth
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic