This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 73699

Summary: create public getter methods to access ui components
Product: guibuilder Reporter: prange <prange>
Component: CodeAssignee: issues@guibuilder <issues>
Status: NEW ---    
Severity: blocker    
Priority: P3    
Version: 5.x   
Hardware: All   
OS: All   
Issue Type: ENHANCEMENT Exception Reporter:

Description prange 2006-03-17 12:11:05 UTC
Hi,
this issue is related to issue 23675.
It also concerns the code generated to access the components created by the 
visual gui builder.

In our project we use the Netbeans form builder to create view classes.
My problem is that our software architecture forces me to access the components 
from outside the view class.
Until now, I modified the Netbeans options (Tools/Options/Miscellaneous/GUI 
Builder/Code generation) to create "public" access modifiers at the declarations 
of the components.

But now, there are new code conventions in our project which prohibit the use of 
the "public" access modifier. The preferred way to access a field of a class is 
to use a public getter method.

So my wish for a future Netbeans release is another option under Tools/Options/
Miscellaneous/GUI Builder/Code generation which leads to the creation of one 
public getter method per component.

Just to clarify my problem:

This is the component declaration in a form's code according to the Netbeans 
default options:
private javax.swing.JLabel nameLabel;

This is how it worked fine for me until our new code conventions came:
public javax.swing.JLabel nameLabel;

And this is how I wish it to be to fulfill our new code conventions:
private javax.swing.JLabel nameLabel;
public javax.swing.JLabel getNameLabel(){
  return nameLabel;
}


Thanks for paying attention to my problem.

Bye, Stefan Prange
Comment 1 prange 2006-03-20 12:38:30 UTC
*** Issue 73700 has been marked as a duplicate of this issue. ***