开发者

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.

  1. Open the form in Form Designer view.
  2. 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.
  3. Select "Customise Code". This will bring up the Code Customizer window.
  4. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜