[NetBeans]changing menuitems



I am using Netbeans and in my class "GenListView" where most of the code is
created by Netbeans I have menu items members with private status which
means that oustide of any instances of "GenListView" NO WAY to simply
change any of those menu items like desabling enabling them.

As I want to do this from a class that I will call hereafter "Other" not
included in GenListView this is what I did :

(a) in class "GenListView" I added this :

- in some methods :
menuItem1=jMenuItem1; //jMenuItem is declared as private by NetBeans
instance = this;

- these 2 methods :
public static GenListView getInstance() {
return instance;
}

public void enableMenuItem(JMenuItem menuItem) {
menuItem.setEnabled(true);
}

- these members :
static public GenListView instance;
public JMenuItem menuItem1;

(b) in class "Other" I added this :

- in some method :
GenListView.getInstance().disableMenuItem(GenListView.getInstance().menuItem1);

It works but looks complex to me ; any way to make it simpler as there is no
possibility for direct access of "jMenuItem1" from other class ?
Regards.


.



Relevant Pages

  • Re: [NetBeans]changing menuitems
    ... is created by Netbeans I have menu items members with private status ... which means that oustide of any instances of "GenListView" NO WAY to ... Maybe have GenListView implement a Listener and register ... when using NetBeans you get help from the gui ...
    (comp.lang.java.help)
  • Re: [NetBeans]changing menuitems
    ... created by Netbeans I have menu items members with private status which ... means that oustide of any instances of "GenListView" NO WAY to simply ... public JMenuItem menuItem1; ... Maybe have GenListView implement a Listener and register itself as a listener to whatever class is changing the state that requires menu items to be disabled? ...
    (comp.lang.java.help)