Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 MouseListener problems in a JFrame
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
blackhawk_prince




PostPosted: Thu May 29, 2008 6:13 pm   Post subject: MouseListener problems in a JFrame

I am making a risk game and I am having problems with the mouseListener and MouseMotionListener. Here is my code so far for the game handler. Currently the mouse methods are not working.

public class GameHandler extends JFrame implements Runnable, ActionListener, MouseListener, MouseMotionListener{

... variables

public GameHandler (ArrayList <Player> playerArrayList, int gameType, int cardOption, boolean autoPlaceUnits
, boolean recycleCards){//constructor

super("Risk: The Game of World Domination");
setLayout(null);

... initialize variables

addMouseListener (this);
addMouseMotionListener (this);
setSize (800,600);
setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
setVisible (true);
}

... gameHandler methods

public void mouseEntered (MouseEvent e){}
public void mouseExited (MouseEvent e){}
public void mousePressed (MouseEvent e){}
public void mouseReleased (MouseEvent e){}
public void mouseMoved (MouseEvent e){
System.out.println ("in mouse Moved");
}
public void mouseDragged (MouseEvent e){}
public void mouseClicked (MouseEvent e){
System.out.println ("in mouse clicked");
}

}

The mouse methods do not work.
GameHandler is called by a NewGame class which is also a JFrame:

if (source == startGame){
if (playersList.size () > 1){
GameHandler gh = new GameHandler (playersList, gameType, cardOption, auto_place, recycle_card);
setVisible (false);
} else {
JOptionPane.showMessageDialog (this, "There must be more than one player", "Cannot Launch", JOptionPane.INFORMATION_MESSAGE);
}
}

The problem might be that addMouseListener (this); think NewGame class is this not the GameHandler class but other than that I dont know what is wrong or how to fix it:( I anyone can help please do.
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 1 Posts ]
Jump to:   


Style:  
Search: