Making Controls public/Global in Netbeans with Java
So I have multiple forms for my current project and I have made classes that 开发者_如何学运维interact and do some utility work behind these forms.
However I am unable to access controls on other forms.
Say I have a text control on Form A and I want to use a class that receives/manipulates data from a completely different Form B.
My classes and Form B cannot see this control.
I have tried going to properties code variable modifiers set to "Public"
Unfortunately this does not seem to do the trick. Any ideas? I appreciate the help!!
I managed to solve the problem if anyone was curious.
Instead of being lazy I create public methods that allow me to communicate with them via setters and getters.
Thank you for anyone who tried to solve this for me.
Here's how you do it in Netbeans 7.2.1.
- Open the form in Form Designer view.
- Right click on the control whose visibility you want to change. You can click in the designer window, or in the Navigation pane to the left.
- Select "Customise Code". This will bring up the Code Customizer window.
- At the bottom of the Code Customizer window is a combo box labelled "Access", which is by default set to "Private". Set this to public.
Your control should now be accessible from other classes.
精彩评论