inheritance - Java boolean not passing from class -


i have many classes in java. want if click on radiobutton on window (my main gui), boolean value passed other classes.

here how "architected". here class window:

class window{     oscillo parent;     graph graph;     boolean b1=true;     boolean b2 = false;      window(oscillo parent){         this.parent = parent;     } }//end class 

here class graph:

   class graph extends jpanel(){          window parent;           // tried boolean values window nothing worked           private class sg{              sg(graphics g, int id){              // tried boolean values window nothing worked           ...           }//end private class     }//end class 

here class data:

    class data{         private oscillo parent;         // tried boolean values window nothing worked         data (oscillo parent){           // tried boolean values window nothing worked         }         ...     }//end class 

here class oscillo

    public class oscillo implements messagelistener{         data data;         window window;         // tried boolean values window nothing worked         ...     }//end class 

i tried several things, super.b1, parent.b1... , on, couldn't boolean values passed 1 class others.

if u me solve problem, grateful ! have nice day !

tom

you should expose them other classes using methods, such:

class window{     oscillo parent;     graph graph;     boolean b1=true;     boolean b2 = false;      window(oscillo parent){         this.parent = parent;     }      // urge choose better names more clear     // both variables , methods     boolean getb1() { return b1; }     boolean getb2() { return b2; }  }//end class 

and use them read values, such:

class graph extends jpanel(){      window parent;       private class sg{          sg(graphics g, int id){          parent.getb1(); //getting b1's value       }//end private class  }//end class 

and on...

when have oscillo object , want access b1 or b2 through its' window object, add method window , chain these calls such:

public class oscillo implements messagelistener{     data data;     window window;      //get b1 or b2 window.getb1() , window.getb2() accordingly     window getwindow() { return window; }  }//end class  class data{     private oscillo parent;     data (oscillo parent){        // might worth checking if window not null,        // depending on architecture , invariants        parent.getwindow().getb1();     }     ... }//end class 

hope helps.


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -