How to access variables from other class

    public boolean inIn(Person p)
        if  (name == p.name && natInsceNo == p.natInsceNo && dateOfBirth == p.dateOfBirth)
             return true;
        else
             return false;
    }//returns true if Person with same name/natInsceNo/dateOfBirth as phello,
here am trying to compare the existing object with another object.
could you please tell me how to access the variables of other class because i meet this error?
name cannot be resolved!
thank you!

public class Person
    protected String name; 
    protected char gender;      //protected attributes are visible in the subclass
    protected int dateOfBirth;
    protected String address;
    protected String natInsceNo;
    protected String phoneNo;
    protected static int counter;//class variable
//Constractor Starts, (returns a new object, may set an object's initial state)
public Person(String nme,String addr, char sex, int howOld, String ins,String phone)
    dateOfBirth = howOld;
    gender = sex;
    name = nme;
    address = addr;
    natInsceNo = ins;
    phoneNo = phone;
    counter++;
public class Store
    //Declaration of variables
    private Person[] list;
    private int count;
    private int maxSize;
//constructor starts
    public Store(int max)
         list = new Person[max];//size array with parameters
         maxSize = max;
         count = 0;
    }//end of store
//constructor ends
//accessor starts  
    public boolean inIn(Person p)
       return (name == p.name && address == p.address && natInsceNo == p.natInsceNo);
    }//returns true if Person with same name/natInsceNo/dateOfBirth as phope it helps now!

Similar Messages

  • How to access variables from other classe through getter ?

    Hi !
    I have 10 classes
    Cau_1.java containing char Cau_1_Answer;
    Cau_2.java... Cau_2_Answer;
    Cau_10.java... Cau_10_Answer;
    and another class Resume_grammar.java with char[] AnswerList = new Char[10] used to hold cau_1_Answer, Cau_2_Answer...Cau_10_Answer.
    but I don't success to get them.
    In Cau_1.java, I do :
    private static char Cau_1_Answer;
    static char getCau_1_Answer() {
              return Cau_1_Answer;
         static void setCau_1_Answer(char cau_1_Answer) {
              Cau_1_Answer = cau_1_Answer;
    if (a.isChecked()) {Cau_1_grammar.setCau_1_Answer('a');}
    if (b.isChecked()) {Cau_1_grammar.setCau_1_Answer('b');}
    if (c.isChecked()) {Cau_1_grammar.setCau_1_Answer('c');}
    if (d.isChecked()) {Cau_1_grammar.setCau_1_Answer('d');}
    Cau_2, Cau_3...are the same way.
    in Resume_grammar.java :
         static char[] AnswerList = new char[10];     
    AnswerList[0] = Cau_1_grammar.getCau_1_Answer();
    AnswerList[9] = Cau_10_grammar.getCau_10_Answer();
    When I make AnswerList display, all is null (nothing displayed).
    Please help ! What I do wrong ?
    Thank you !

    Johnny.vn wrote:
    Cau_1 is Question_1 (Vietnamese).
    I am developing a academic test application with many question and finally display the result of the test.
    Thank you.Back to the original question: why do you need to define different classes for different questions? Do they really behave differently in a way that can't be captured by a single class?

  • Accessing public variables from other classes

    Probably a simple questions, but how can I access a variable from another class. My exact situation is as follows.
    A class called WorldCalender has a variable which is defined: public int hour; (the value is given to it elsewhere).
    I want to access this variable and increase it by one in a subroutine in the class Hour. In this class I have put: WorldCalender.hour++; but it doesn't seem to work. How should I do it?

    don't expose the hour variable at all.
    have a method eg addToHourBy( int hrs )
    Probably a simple questions, but how can I access a
    variable from another class. My exact situation is as
    follows.
    A class called WorldCalender has a variable which is
    defined: public int hour; (the value is given to it
    elsewhere).
    I want to access this variable and increase it by one
    in a subroutine in the class Hour. In this class I
    have put: WorldCalender.hour++; but it doesn't seem to
    work. How should I do it?

  • How to access function from Top Class to Function of class that contain the the member variable of TopClass

    Dear All,
    is there any way that i can access function or member variable of aggregate class.
    i am working in Visual Studio 2010 
    and making win32 dll with mfc Support. i am new in dll system. just learning and doing.
    previously all in exe and i am working this like
    CTestDoc*pDoc = (CTestDoc*)GetTestDocument();
    somevar = pDoc->xDoc.mVar.GetValue (); 
    now i am trying to put all in dll. so getting problem 
    will i get help on this. thanks in advance.
    below code is just an example.
    for example
    // dll 1
    class aaa : public BaseClass
    public:
    int Index;
    char *cName;
    void doSometing()
    if (GetCurBColor() == 125) // how to access GetCurBColor function of the
    color = GetCurBColor();
    long color;
    // dll 2
    class bbb :public BaseClass
    public:
    int Index;
    long lSize;
    long color;
    void doSometing();
    // dll 3
    class DDD
    public:
    vector <aaa> va;
    vector <bbb> vb;
    int cura;
    int curb;
    long GetCurBColor ()
    return vb[curb].color;
    };// MFC doc/view support
    /// in exe in document
    class inExe
    public:
    DDD d;
    void addB()
    { bbb bb;
    bb.color = 152;
    d.vb.push_back(bb);
    bb.color = 122;
    d.vb.push_back(bb);
    bb.color = 1232;
    d.vb.push_back(bb);
    d.curb = 1;
    void addA()
    { aaa aa;
    aa.color = 152;
    d.va.push_back(aa);
    aa.color = 1232;
    d.va.push_back(aa);
    aa.color = 1542;
    d.va.push_back(aa);
    aa.color = 15;
    d.va.push_back(aa);
    d.cura = 2;
    d.va [1].doSometing ();

    Dear All,
    is there any way that i can access function or member variable of aggregate class.
    i am working in Visual Studio 2010
    and making win32 dll with mfc Support. i am new in dll system. just learning and doing.
    previously all in exe and i am working this like
    CTestDoc*pDoc = (CTestDoc*)GetTestDocument();
    somevar = pDoc->xDoc.mVar.GetValue ();
    now i am trying to put all in dll. so getting problem
    What problem?
    The rules of C++ do not change because some of the code ins in a DLL. But the classes in a DLL need to be exported. See for example
    https://msdn.microsoft.com/en-us/library/81h27t8c.aspx
    You should also supply a macro so that the class header can be used in both the DLL and the client. See for example
    http://stackoverflow.com/questions/14980649/macro-for-dllexport-dllimport-switch
    If  you exchange memory between the DLL and the client (as your example will do, because of the std::vector content), you should also be sure to use the same version of the compiler for each module, and to dynamically link to the CRT.
    I would also advise you to start with a less complicated scenario, with just one DLL.
    David Wilkinson | Visual C++ MVP

  • Use of variables from other class

    hallo,
    i have two classes A and B
    i would like to access a variable of the class B out of A class
    without class A extends B or
    A classA = new A();
    to use
    i attempted it with a constructor
    class A{
        B klb;
        public A(B b1){
        this.klb = b1;
       int a;
       a= klb.varausB;
    }with that I get, however, a NullPointerException
    in a similar form i saw it already once and it functioned
    somebody can help me?

    that is it what I mean
    public class ClassA {
    ClassB clb;
    public ClassA (ClassB cb){
    this.clb = cb;
    public static void main(String[] args) {
    System.out.println("Var from class B:
    class B: "+clb.varb1);// there is an error, i know
    but how it is right?
    public class ClassB {
    public String varb1 ="var b1";
    }nevertheless so similarly it should function, or?So if you create an instance of ClassA, clb will be initialized. But you don't do that in main. Hence your errors:
    1) You're not calling the constructor, so clb is null
    2) You're trying to access an instance variable without having an instance, so clb is not only null, it actually doesn't exist.
    public static void main(String[] args) {
      Class A myA = new ClassA();
      System.out.println("Var from class B: "+ myA.clb.varb1);
    }You're outside of any object, ehnce you need to address clb through an instance of ClassA.

  • How to get variable from another class?

    I have 2 classes. In first I have int variable. In second class I need to get this variable value. How I can make it?
    import javax.microedition.lcdui.*;
    import java.io.*;
    import java.util.*;
    public class ChooseLessons extends Form implements CommandListener, ItemStateListener
         ChoiceGroup lessons;     // Choice Group of preferences
         Dictionary     dictionary;
         int volumeSize;
         ChooseLessons(Dictionary dictionary)
              int volumeSize = 15;
         public void commandAction(Command c, Displayable s)
              if (c == Dictionary.BEGIN_CMD) {
                   new TeachForm(dictionary, this);
    import javax.microedition.lcdui.*;
    import java.util.*;
    public class TeachForm extends Form implements CommandListener     
         Dictionary               dictionary;
         ChooseLessons          lessons;
         TeachForm(Dictionary dictionary, ChooseLessons lessons) {
              super(Locale.WORD);
              this.dictionary = dictionary;
              this.lessons = lessons;
              lessons.volumeSize(); // HERE I NEED VARIABLE VALUE FROM PREVIOUS CLASS
    }Edited by: Djanym on Mar 16, 2009 4:43 PM

    This is a classic problem that coders run into when trying to get their head around object-oriented programing. Since you have a class that should be modeled after a real world object, as far as that object is concerned, no one else needs to know the details of it - without asking nicely. This is where you should set up some getters and setters, which are methods that allow fields in a class to reveal themselves or allow their states to be changed in a orderly fashion.
    There are a number of fields that never need to be known outside of the class. Then there are some fields you would like to let people know about, but don't want them to have the ability to change them. In the example below, there are to getter methods allow return of the necessary fields. If you made these public, there is a possibility that someone utilizing this field may change it outside of its intended use, or access them without them being ready for public consumption.
    Class test {
    //These private variables are only visible from the class
    private int grade1 = 0;
    private int grade2 = 0;
    private int grade3 = 0;
    private float average = 0;
    private int gradeboost = 0;
    //This method sets the gradeboost field to one desired by the instructor
    void setboost(int boost) {
    gradeboost = boost;
    //These methods accept test scores and compute the average for three test
    //Notice that the calculated average may not be the true average of the three test scores
    //because of the possibility of gradeboost calculation being greater than 1
    void test1(int score) {
             grade1 = score;
             average = (grade1 + grade2 + grade3 + gradeboost)/3;
    void test2(int score) {
             grade2 = score;
             average = (grade1 + grade2 + grade3 + gradeboost)/3;
    void test3(int score) {
             grade3 = score;
             average = (grade1 + grade2 + grade3 + gradeboost)/3;
    //This is a getter method, which provides read access to the private variable average
    //If someone just had public access to the grades and wanted to take their own average
    //They would miss how the gradeboost field affects the final outcome.
    float getAverage() {
        return average;
    //Here is a getter method, which accepts an argument to determine which test score to return
    //Notice that this isn't the true testscore, but it has been modified by the gradeboost field.
    //If the user had public access to the true testscore, it wouldn't take into account the gradeboost calculation!!
    //This is how a getter can control exactly what a user has access to.
    float get testScore(int test) {
    float testresult = 0;
    if (test = 1) {
           testresult = (grade1+ gradeboost) / 3;
    if (test = 2) {
           testresult = (grade2+ gradeboost) / 3;
    if (test = 3) {
           testresult = (grade3+ gradeboost) / 3;
    return testresult;
    }

  • Accessing string from other classes

    Sorry if this seems simple to you, but i'm having problems accessing four string that are declared and used in my public class from another class.
    I've tried declaring the strings public but it still says 'cannot resolve symbol' when i try to compile.
    Help much appreciated.
    fightspam

    Yep, heres my code(sorry if it's a bit untidy):
    //Zimmerman M3 email client.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.io.*;
    class where extends JFrame implements ActionListener
         private JLabel path;
         private JTextField pathText;
         private String pathFile;
         private JButton save;
         File outputFile = new File(pathFile);
         public where()
              super("Save Email");     
              Container f=getContentPane();
                   f.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5));
              f.setBackground(Color.lightGray);
              path = new JLabel("Path: ");
              f.add(path);
              pathText = new JTextField(20);
              f.add(pathText);
              save = new JButton("Save");
              f.add(save);
              this.setSize(300, 100);
         public void actionPerformed(ActionEvent q)
              pathFile = pathText.getText();
              try
                   FileWriter out = new FileWriter(outputFile);
                   out.write(zimmernorm.toFile);
                   out.write(zimmernorm.fromFile);
                   out.write(zimmernorm.subjectFile);
                   out.write(zimmernorm.bodyFile);
                   out.close();
              catch(IOException err)
                   System.exit(0);
    class about extends JFrame
         private JLabel title;
         public about()
              super("About Zimmerman M3");
              Container d=getContentPane();
                   d.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5));
              d.setBackground(Color.lightGray);
              title = new JLabel("Zimmerman M3 by Louis Goddard, 2003");
              d.add(title);
              this.setSize(246, 62);
    class newmail extends JFrame implements ActionListener
         public static String toFile, fromFile, subjectFile, bodyFile;
         public JTextField To, From, Subject;
         private String toBuffer, fromBuffer, subjectBuffer, bodyBuffer;
         private JButton send, clear;
         private JTextArea Body;
         private JLabel toLabel, fromLabel, subjectLabel;
         private JMenuBar mb;
         private JMenu File, Edit;
         private JMenuItem New, Sender, Copy, Paste, About;
         public newmail()
                    super("New Email");
              Container c=getContentPane();
                   c.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5));
              c.setBackground(Color.lightGray);
              //<MENU STUFF!!!>     
                   mb = new JMenuBar();
                   File = new JMenu("File");
                   Edit = new JMenu("Edit");
                   New = new JMenuItem("New");
                   Sender = new JMenuItem("Save");
                   Copy = new JMenuItem("Copy");
                   Paste = new JMenuItem("Paste");
                   File.add(New);
                   New.addActionListener(this);
                   New.setActionCommand("1");
                   File.add(Sender);
                   Sender.addActionListener(this);
                   Sender.setActionCommand("2");
                   Edit.add(Copy);
                   Copy.addActionListener(this);
                   Copy.setActionCommand("3");
                   Edit.add(Paste);
                   Paste.addActionListener(this);
                   Paste.setActionCommand("4");
                   mb.add(File);
                   mb.add(Edit);
                   setJMenuBar(mb);
              //</MENU STUFF!!!>     
              toLabel = new JLabel("To:          ");
              c.add(toLabel);
              To = new JTextField(35);
              c.add(To);
              fromLabel = new JLabel("From:     ");
              c.add(fromLabel);
              From = new JTextField(35);
              c.add(From);
              subjectLabel = new JLabel("Subject:");
              c.add(subjectLabel);
              Subject = new JTextField(35);
              c.add(Subject);
              Body = new JTextArea(12,40);
              c.add(Body);
              send = new JButton("Send");
                    c.add(send);
              clear = new JButton("Clear");
                    c.add(clear);
              clear.addActionListener(this);
              clear.setActionCommand("6");
              this.setSize(459, 364);
              public static void main(String []args)
                   JFrame.setDefaultLookAndFeelDecorated(true);
                   new newmail().show();
              public void actionPerformed(ActionEvent e)
                   String s = e.getActionCommand();
                   if (s == ("1"))
                   new newmail().show();
                   else if (s == ("2"))
                   new where().show();
                   toFile = To.getText();
                   fromFile = From.getText();
                   subjectFile = Subject.getText();
                   bodyFile = Body.getText();
                   else if (s == ("3"))
                   bodyBuffer = Body.getSelectedText();
                   toBuffer = To.getSelectedText();
                   fromBuffer = From.getSelectedText();
                   subjectBuffer = Subject.getSelectedText();
                   else if (s == ("4"))
                   Body.setText(bodyBuffer);
                   To.setText(toBuffer);
                   From.setText(fromBuffer);
                   Subject.setText(subjectBuffer);
                   else if (s == ("5"))
                   new about().show();
                   else if (s == ("6"))
                   To.setText("");
                   From.setText("");
                   Subject.setText("");
                   Body.setText("");
    public class zimmernorm extends JFrame implements ActionListener
         public String toFile, fromFile, subjectFile, bodyFile;
         private String toBuffer, fromBuffer, subjectBuffer, bodyBuffer;
         private JMenuBar mb;
         private JMenu File, Help, View;
         private JMenuItem New, About, Inboxmenu, Outboxmenu, Savedmenu;
         public zimmernorm()
                    super("Zimmerman M3");
              Container c=getContentPane();
                   c.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5));
              c.setBackground(Color.lightGray);
              //<MENU STUFF!!!>     
                   mb = new JMenuBar();
                   File = new JMenu("File");
                   View = new JMenu("View");
                   Help = new JMenu("Help");
                   New = new JMenuItem("New");
                   About = new JMenuItem("About");
                   Inboxmenu = new JMenuItem("Inbox");
                   Outboxmenu = new JMenuItem("Outbox");
                   Savedmenu = new JMenuItem("Saved");
                   File.add(New);
                   New.addActionListener(this);
                   New.setActionCommand("1");
                   Help.add(About);
                   About.addActionListener(this);
                   About.setActionCommand("5");
                   View.add(Inboxmenu);
                   Inboxmenu.addActionListener(this);
                   Inboxmenu.setActionCommand("7");
                   View.add(Outboxmenu);
                   Outboxmenu.addActionListener(this);
                   Outboxmenu.setActionCommand("8");
                   View.add(Savedmenu);
                   Savedmenu.addActionListener(this);
                   Savedmenu.setActionCommand("9");
                   mb.add(File);
                   mb.add(Help);
                   mb.add(View);
                   setJMenuBar(mb);
              //</MENU STUFF!!!>     
              this.setSize(1024, 768);
                    this.setDefaultCloseOperation( EXIT_ON_CLOSE );
              public static void main(String []args)
                   JFrame.setDefaultLookAndFeelDecorated(true);
                   new zimmernorm().show();
              public void actionPerformed(ActionEvent e)
                   String s = e.getActionCommand();
                   if (s == ("1"))
                   new newmail().show();
                   else if (s == ("5"))
                   new about().show();

  • Loading XML using a custom class and accessing it from other classes?

    I began with a class for a movie clip rollover function
    FigureRollOver. It works marvellously. Three things happen:
    1) it loads XML from a file "mod1_fig1.xml" and uses another
    class, XMLMember, to retool the scoping of the XML so that I can
    get at it
    2) an onload call inside of XMLMember calls the myOnLoad
    function and transfers the XML into an array.
    3) so long as the array is finished building, rolling over a
    movie clip attaches a new movie clip with the rollover text in it.
    But I don't want all those functions in one because I need it
    to be more dynamic, starting with being able to load any old xml
    file instead of just "mod1_fig1.xml", plus it seems like
    overbuilding to have all of that in one class, so I've separated
    out the loading of the XML and building of the array into its own
    class, FigureXMLLoader. FigureRollOver is then left to just attach
    the rollover with text in it, extracted from the array built by the
    new class.
    Problem is, though the array builds inside FigureXMLLoader, I
    can't figure out how to make it available outside the class. I know
    that I'm constructing things in the wrong order, and that the array
    needs to be somehow built inside the class function to be
    available, but I can't figure out how to do that. A cruddy
    work-around is to put a function call at the end of the building of
    the array, which calls yet ANOTHER function on the main timeline of
    my .swf to put the array I've just built into a new variable. This
    works, but it's messy. It seems like I should be able to have one
    line of script in the .swf that generates an array on the main
    timeline (or just a public array) which I can then access from my
    FigureRollOver class:
    var myRollOvers:Array = new FigureXMLLoader("mod1_fig1.xml");
    Here is FigureXMLLoader (see comments in the code for more
    details) which obviously does not return an array as it is, because
    of all the working around I've had to do. Note the "testing"
    variable, which can be traced from the main timeline of the .swf,
    but I will get "not what I want" because of course the array hasn't
    been built yet, and never will be, inside of the declaration as it
    is. How do I get it in there so I can return an array?
    Thanks!

    Suggest you ask this question in the Actionscript forum as
    this forum is
    more tuned to database integration questions.
    You can create arrays outside a class and pass them into it
    by reference and
    visa versa build arrays inside a class and pass out via
    reference.
    The preferred approach is to place the array in a class and
    not expose it.
    Then add methods to use the array or should we say to use the
    class.
    Lon Hosford
    www.lonhosford.com
    Flash, Actionscript and Flash Media Server examples:
    http://flashexamples.hosfordusa.com
    May many happy bits flow your way!
    "maija_g" <[email protected]> wrote in
    message
    news:ed4i43$9v0$[email protected]..
    > Update: I've now put this on the main timeline of the
    .swf:
    >
    > myRollOversLoaded = false;
    > var myRollOvers:Array;
    > var roll_content = new FigureXMLLoader("mod1_fig1.xml");
    >
    > And inside the "myOnLoad" function in FigureXMLLoader,
    just after the
    > while
    > loop I've put this:
    >
    > _root.myRollOversLoaded = true;
    > _root.myRollOvers = figure_arr;
    >
    > The movie clip rollover won't act until
    myRollOversLoaded is true. It
    > works,
    > but it still seems klugey. Any suggestions for a more
    elegant solution
    > would be
    > appreciated.
    >

  • Accessing variable from another class

    Say I want to access String ABC from class XYZ from my main class. I have already created the object for the class I just don't know the syntax for accessing the variable.
    This is just an example. I figured this is just a problem of finding the right syntax so I didn't bother creating a compiling code.
    public class test{
    public static void main(String[]args){
         XYZ xyz = new XYZ ();
         String a = abc.XYZ(); // this is where i want to directly access the variable abc. i know this isn't correct and it's what im trying to find out how to do.
    public class XYZ{
         String abc = "hi";
    }Edited by: aznprdgy on Nov 3, 2009 2:13 PM

    No, that isn't possible.
    abc is said to be a local variable. And it's only useable within method().
    It's part of the job of the class Xyz to control the access to its state. As an example:
    public class Test {
        public static void main(String[] args) {
            Xyz xyz = new Xyz()
            String a = xyz.getSpecialValue();
    public class Xyz {
        private String a;
        public String getSpecialValue() {
            return a;
        public void method() {
            a = "hi";
    }Note that a won't be reference to the string "hi" until after method() has been called.

  • How to pass a variable from one class to another class?

    Hi,
    Is it possible to pass a variable from one class to another? For e.g., I need the value of int a for calculation purpose in method doB() but I get an error <identifier> expected. What does the error mean? I know, it's a very, very simple question but once I learn this, I promise to remember it forever. Thank you.
    class A {
      int a;
      int doA() {
          a = a + 1;
          return a;
    class B {
      int b;
      A r = new A();
      r.a;  // error: <identifier> expected. What does that mean ?
      int doB() {
         int c = b/a;  // error: operator / cannot be applied to a
    }Thank you!

    elaine_g wrote:
    I am wondering why does (r.a) give an error outside the method? What's the reason it only works when used inside the (b/r.a) maths function? This is illegal syntax:
    class B {
      int b;
      A r = new A();
      r.a;  //syntax error
    }Why? Class definition restricts what you can define within a class to a few things:
    class X {
        Y y = new Y(); //defining a field -- okay
        public X() { //defining a constructor -- okay
        void f() { //defining a method -- okay
    }... and a few other things, but you can't just write "r.a" there. It also makes no sense -- that expression by itself just accesses a field and does nothing with it -- why bother?
    This is also illegal syntax:
    int doB() {
          A r = new A();
          r.a;  // error: not a statement
    }Again, all "r.a" does on its own is access a field and do nothing with it -- a "noop". Since it has no effect, writing this indicates confusion on the part of the coder, so it classified as a syntax error. There is no reason to write that.

  • How  add buttons to Jframe from other class

    Hi, a have a little problem;)
    I want make a JFrame, but i want to add JButtons from other class. Now I have something like that:
    My JFrame class:
    package windoow;
    import javax.swing.*;
    import java.awt.*;
    public class MyWindow extends JFrame {
           Butt buttons ;
            public Window(String s) {
                     super(s);
                    this.setSize(600, 600);
                    this.setVisible(true);
                    Buttons();
                public void Buttons(){
                    setLayout(null);            
                   buttons = new Butt();
                   buttons.mywindow =this;
    } My class with buttons:
    package windoow;
    import javax.swing.JButton;
    public class Butt {
            MyWindow mywindow;
            JButton b1;
            Butt(){
                      b1 = new JButton("Button");
                      b1.setBounds(100,100,100,20);
                      mywindow.add(b1);  
    } and i have NullPointerException.
    When i try to make new MyWindow in Butt clas i have something like StackOverFlow.
    what should i do?

    Your null pointer exception is occuring because, in your Butt() constructor, you are calling mywindow.add(b1), but you don't set mywindow until after you call the constructor in the MyWindow::Buttons() method.
    And, if you try to create a new MyWindow() in your Butt() constructor, and, assuming that you are calling the MyWindow::Window(String s) method from the MyWindow() constructor (which is not clear from the code fragment you posted), then Butt() calls new MyWindow() which calls Window(String s) which calls Butt() which calls ... and so on, until the stack overflows.
    One possible solution ... pass your MyWindow reference into your Butt() constructor as this, as so:
    public void Buttons()
       // stuff deleted
      buttons = new Butt( this );
       // stuff deleted
    // AND
    Butt( MyWindow mw )
       // stuff deleted
      mywindow = mw;
      mywindow.add( b1 ); // b1 created in stuff deleted section  
    }Also, I would call setVisible(true) as the last thing I did during the construction of the frame. This realizes the frame, and from that point forward, most changes to the frame should be made on the event thread.
    ¦ {Þ                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • OBIEE 11g How to pass variable from one prompt to another prompt in dashboard page.

      How to pass variable from one prompt to another prompt in dashboard page.
    I have two prompt in dashboard page as below.
    Reporttype
    prompt: values(Accounting, Operational) Note: values stored as
    presentation variable and they are not coming from table.
    Date prompt values (Account_date, Operation_date)
    Note:values are coming from dim_date table.  
    Now the task is When user select First
    Prompt value  “Accounting” Then in the
    second prompt should display only Accounting_dates , if user select “operational”
    and it should display only operation_dates in second prompt.
    In order to solve this issue I made the
    first prompt “Reporttype” values(Accounting, Operational) as presentation
    values (custom specific values) and default presentation value is accounting.
    In second prompt Date are coming from
    dim_date table and I selected Sql results as shown below.
    SELECT case when '@{Reporttype}'='Accounting'
    then "Dates (Receipts)"."Acct Year"
    else "Dates (Receipts)"."Ops
    Year"  End  FROM "Receipts"
    Issue: Presentation variable value is not
    changing in sql when user select “operation” and second prompt always shows
    acct year in second prompt.
    For testing pupose I kept this presentation
    variable in text object of dashboard and values are changing there, but not in
    second prompt sql.
    Please suggest the solution.

    You will want to use the MoveClipLoader class (using its loadClip() and addListener() methods) rather than loadMovie so that you can wait for the file to load before you try to access anything in it.  You can create an empty movieclip to load the swf into, and in that way the loaded file can be targeted using the empty movieclip instance name.

  • Handeling EventListeners given from other classes...

    Hello again,
    I got the folloing Problem:
    I've got a Frame-Class, with calls a Class from jPanel, this Panel has a button.
    My Problem is this, Is there a way, to handle the button-event from the Parent-Frame?
    Means this:
    MyPanel mp = new MyPanel();
    this.add(mp);
    // Here to wait for the button event, and do something.
    If anybody has a solution, thx alot.

    don't expose the hour variable at all.
    have a method eg addToHourBy( int hrs )
    Probably a simple questions, but how can I access a
    variable from another class. My exact situation is as
    follows.
    A class called WorldCalender has a variable which is
    defined: public int hour; (the value is given to it
    elsewhere).
    I want to access this variable and increase it by one
    in a subroutine in the class Hour. In this class I
    have put: WorldCalender.hour++; but it doesn't seem to
    work. How should I do it?

  • Method not accessible from other classes

    Hi,
    I ve defined a class and would like to create an instance of it from another class. That works fine, I am also able to access class variables. However the class method "calcul" which is defined as following, is not accessible from other classes:
    class Server {
    static String name;
    public static void calcul (String inputS) {
    int length = inputS.length();
    for (int i = 0 ; i < length; i++) {
    System.out.println(newServer.name.charAt(i)); }
    If I create an instant of the class in the same class, the method is then available for the object.
    I am using JBuilder, so I can see, which methods and variables are available for an object. Thanks for your help

    calcul is a static method, that means you do not need an instance of server to run this method. This method is also public, but your class Server is not, your Server class is package protected. So only classes within the same package has Server can use its method. How to use the calcul method?// somewhere in the same package as the Server class
    Server.calcul( "toto" );

  • Moving Variable from one class to another.

    I need to get a Variable from one class to another how would I do this?

    Well this is a very tipical scehario for every enterprise application. You always create logger classes that generate log files for your application, as that is the only way to track errors in your system when its in the production enviorment.
    Just create a simple class that acts as the Logger, and have a method in it that accepts a variable of the type that you are are trying to pass; most commonly a String; but can be overloaded to accept constom classes. e.g.
    class Logger
      public void log(String message)
        writeToFile("< " + new Date() + " > " + message);
      public void log(CustomClass queueEvent)
        log("queue message was: " + queueEvent.getMessage() + " at: " + queueEven.getEventTime());
    }Hope this makes things clearer
    Regards
    Omer

Maybe you are looking for

  • Help with PDF form responses

    Hey there! I have two issues with online form data collection and am completely stumped. It's a real struggle to find useful documentation for Acrobat forms! #1 - I have created a form uploaded it to Acrobat.com, and have been able to collect test fo

  • Inserting HTML into a table?

    I am trying to find an easier method of inserting html code into a column of type varchar2. I have to insert 100's of lines of html into a table weekly and the inserts keep failing because of special charecters within the html code itself. I have wri

  • Transferring playlists from iPod Classic to iTunes 11

    My hard drive crashed, but I had my song backed up.  However, now I lost all of my iTunes playlists.  How can I transfer the playlists from my iPod Classic to iTunes 11.0.1.12

  • Account assignment tab  not available in ME51N

    hello, can any one replay in purchase requisition account assignment tab is not there pls let me know how i have to configure it. rk

  • Make to order(MTO) and make to stock(MTS)

    Hi friends Please Send the details about Make to order(MTO) and make to stock(MTS) process and configuration .if u have any documents pls send to my mail ID : [email protected] Regards Balu