Mouse Listeners to Draw?
Alright, I've got a program that, using buffered images and whatnot, will load an image onto an instance of a class called ImagePanel. The contents of ImagePanel are show in an instance of another class, ImageViewer. ImageViewer basically functions as a GUI/source of interactivity. What I need to do is, with a series of mouse listeners, get the location of each mouse event and set that pixels color to a user specified color. My issues are coming when I try to add the mouse listener. Basically I'm trying to add the listener to the instance of ImagePanel, and it's not working. In image viewer there is a method that creates the frame, with all the menu items in everything. In there I add the actions listeners:
imagePanel.addMouseListener(new MouseListener()
{
publicvoid mousePressed(MouseEvent e)
{
if(drag ==true)
{
return;
}
int x = e.getX();
int y = e.getY();
currentImage.setPixel(x, y, drawColor);
drag =true;
}
});
imagePanel.addMouseListener(new MouseListener()
{
publicvoid mouseReleased(MouseEvent e)
{
drag =false;
}
});
imagePanel.addMouseMotionListener(new MouseMotionListener()
{
publicvoid mouseDragged(MouseEvent e)
{
int x = e.getX();
int y = e.getY();
currentImage.setPixel(x, y, drawColor);
}
});
...and at the end of the program I've got (to satisfy the interfaces):
publicvoid mouseClicked(MouseEvent e){}
publicvoid mouseEntered(MouseEvent e){}
publicvoid mouseExited(MouseEvent e){}
publicvoid mouseMoved(MouseEvent e){}
As is, this wont compile. It spits out an error saying haven't overridden the above methods, and the compiler (BlueJ) points to the first line of the code adding the listeners to the instance of ImagePanel.
The entire class is over 450 lines to I'm reluctant to post all of it here, but if you need to see it I can easily send it to you however you prefer.

