Hi all,
Having a little trouble with getting this mouse listener to work, and I am ripping my hair out cause I can't see what in the world the problem is, any help would be appreciated!
Code:public class MainWindow extends JFrame implements MouseListener { private Canvas renderCanvas; /** Creates a new instance of Main */ public MainWindow() { super( "Game" ); // Exit the program when we close the window for god's sake! setDefaultCloseOperation( EXIT_ON_CLOSE ); // We don't want to repaint when the OS says we need to setIgnoreRepaint( true ); addMouseListener( this ); //addMouseMotionListener(myListener); GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gd = ge.getDefaultScreenDevice(); // Setup the Canvas renderCanvas = new Canvas() { public Dimension getPreferredSize() { return new Dimension( 1024, 768 ); } }; add( "Center", renderCanvas ); pack(); // Put the window in the center of the screen Point cp = ge.getCenterPoint(); cp.translate( -getWidth()/2, -getHeight()/2 ); setLocation( cp.x, cp.y ); setResizable( false ); setVisible( true ); renderCanvas.createBufferStrategy( 2 ); } public BufferStrategy getBufferStrategy() { return (renderCanvas == null) ? super.getBufferStrategy() : renderCanvas.getBufferStrategy(); } public Dimension getDimensions() { return (renderCanvas == null) ? super.getSize() : renderCanvas.getSize(); } public void mouseClicked(MouseEvent event) { int test = 0; } public void mouseEntered(MouseEvent event) { int test = 0; } public void mouseExited(MouseEvent event) { } public void mousePressed(MouseEvent event) { } public void mouseReleased(MouseEvent event) { int test = 0; }


Reply With Quote


Bookmarks