0

So I created a handling class that implements the MouseListener (this one works). As the program runs some resources are being loaded and it creates the panel to be used for the MouseListener etc... Then when everything is done it's suppose to enter() the panel and add the MouseListener. enter() below:

@Override
public void enter() {

    gh = new Game_handler(gr); //gh works fine and implements mouselistener
    this.addMouseListener(gh); //gr is nothing but a chunk of data

    this.requestFocus();
}

Now for some reason the MouseListener doesn't listen! I 've done some system prints and I know the panel is created then the MouseListener class and then it's added to the panel. But for some reason it just wont do anything!

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
David Ekermann
  • 87
  • 3
  • 13
  • I believe that the problem has something to do with how one panel swaps out another one.. There is a panel in the frame before this one that gets swapped out for this one when the loadin part is done... – David Ekermann Jan 21 '13 at 18:53
  • 2
    no issue for better help sooner post an [SSCCE](http://sscce.org/), short, runnable, compilable – mKorbel Jan 21 '13 at 18:53
  • 1
    You cannot put any "chunk of data" inside `addMouseListener`.For better help sooner,post an [SSCCE](http://sscce.org/) as suggested by @mKorbel – joey rohan Jan 21 '13 at 18:54
  • the chunk of data is not inside the mouselistener it's inside the game_handler (which implements mouselistener) – David Ekermann Jan 21 '13 at 19:02
  • 2
    *"it's inside the game_handler"* Achieve this *first* in an SSCCE that uses only J2SE components. Likely then you will be able to transfer that knowledge to the 3rd party framework. As as aside: Look at [`CardLayout`](http://stackoverflow.com/questions/5665156/calling-awt-frame-methods-from-subclass/5786005#5786005) for changing between panels. – Andrew Thompson Jan 21 '13 at 19:41

0 Answers0