Having problems calling a non-static method for a static context

Discussion in 'Java' started by iMohed@live.se, May 12, 2009.

  1. Guest

    I guess the title says it all. I just dont understand why i cant cal
    my Main.play() from my Model class. Both in the same package.

    Model class short :

    public void actionPerformed(ActionEvent e) {
    Object source = e.getSource();
    clickButton(source);
    }

    public void clickButton(Object o) {
    int i = 0;
    for (MButton s : this.but) {
    if (s == o) {
    Main.play(i);
    }
    }
    }

    Main class short :

    public void play(int k) throws IOException {
    while (game.finish == false) {
    game.doTurn(k);
    int j = 0;
    for (Model.Square squares : game.sq) {
    communication[j] = squares.value;
    j++;
    }
    gameGfx.setColors(communication);
    }
    }

    Any ideas guys and gals ??
    Mohamed Haidar.
     
    , May 12, 2009
    #1
    1. Advertising

  2. wrote:
    > I guess the title says it all. I just dont understand why i cant cal
    > my Main.play() from my Model class. Both in the same package.
    >
    > Model class short :
    >
    > public void actionPerformed(ActionEvent e) {
    > Object source = e.getSource();
    > clickButton(source);
    > }
    >
    > public void clickButton(Object o) {
    > int i = 0;
    > for (MButton s : this.but) {
    > if (s == o) {
    > Main.play(i);
    > }
    > }
    > }
    >
    > Main class short :
    >
    > public void play(int k) throws IOException {
    > while (game.finish == false) {
    > game.doTurn(k);
    > int j = 0;
    > for (Model.Square squares : game.sq) {
    > communication[j] = squares.value;
    > j++;
    > }
    > gameGfx.setColors(communication);
    > }
    > }
    >
    > Any ideas guys and gals ??
    > Mohamed Haidar.


    Either new Main().play() or make play static.

    --

    Knute Johnson
    email s/nospam/knute2009/

    --
    Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
    ------->>>>>>http://www.NewsDemon.com<<<<<<------
    Unlimited Access, Anonymous Accounts, Uncensored Broadband Access
     
    Knute Johnson, May 12, 2009
    #2
    1. Advertising

  3. Lew Guest

    wrote:
    > I guess the title says it all.


    Not really. The convention here is for the body of a post to stand on its own.

    --
    Lew
     
    Lew, May 13, 2009
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Gary
    Replies:
    1
    Views:
    3,987
    Ryan Stewart
    Jan 16, 2004
  2. Michael
    Replies:
    3
    Views:
    4,940
    Adam Jenkins
    Jan 27, 2004
  3. G. Burton
    Replies:
    2
    Views:
    59,896
    Sudsy
    Feb 21, 2004
  4. Johannes Beekhuizen
    Replies:
    14
    Views:
    1,342
    John B. Matthews
    Aug 5, 2005
  5. Johannes Beekhuizen
    Replies:
    0
    Views:
    1,538
    Johannes Beekhuizen
    Aug 5, 2005
Loading...

Share This Page