mouseDown(Event evt, int x, int y) Depreciation Help!
Hi,
I would just like to ask if anyone could help me along a little bit and give me some insight as what to do to change this into the non-depreciated format...
I've looked up on the list here, http://java.sun.com/j2se/1.4.2/docs/api/deprecated-list.html, and it states it has been replaced with processMouseEvent(MouseEvent).
I've tried to replace this with this code, but i get error after error..
Could anyone help me with this? I'm hitting a brick wall...
Thanks!
-Crawf
public boolean mouseDown(Event evt, int x, int y) {
if (x >= 8 && y >= 8 && x <= 269 && y <= 269) {
rgbXSelect1 = Math.max(0, Math.min(255, x - 10));
rgbYSelect1 = Math.max(0, Math.min(255, y - 10));
Graphics g = getGraphics();
DrawBackground(g);
DrawSelector(g);
} else
if (x >= 275 && y >= 8 && x <= 286 && y <= 263) {
rgbYSelect2 = Math.max(0, Math.min(255, y - 10));
viewColor = new Color(pixels2[rgbYSelect2 * 10]);
MakeImageCanvas();
Graphics g = getGraphics();
DrawBackground(g);
} else {
return false;
}
return true;
}
[1361 byte] By [
crawf] at [2007-11-11 8:50:07]

# 1 Re: mouseDown(Event evt, int x, int y) Depreciation Help!
Did you take a look at the processMouseEvent(Event e) in the API documentation for the Component class? It refers you to the need to implement MouseListener interface, to register the listener with the component, and then that listener's coding the response to the event which is generated by the mouse button down, or released, or whatever.
Look here (then follow the links, and take a look at the Java Tutorial about implementing a listener for the handling of events):
http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Component.html#mouseDown(java.awt.Event,%20int,%20int)
nspils at 2007-11-11 22:34:11 >

# 2 Re: mouseDown(Event evt, int x, int y) Depreciation Help!
does the processMouseEvent(MouseEvent e) have to be void? while being boolean, it doesnt seem to work...hmmm, this is really wrecking up my program lol! And i still dont know if i'm doing everything right, because nothing seems to be working...
this is the applet so far...
public void mouseMoved (MouseEvent e) {}
public void mouseDragged (MouseEvent e) {}
public void mouseReleased (MouseEvent e) {}
public void mouseClicked (MouseEvent e) {}
public void mouseEntered (MouseEvent e) {}
public void mouseExited (MouseEvent e) {}
public void mousePressed (MouseEvent e) {}
public void processMouseEvent(MouseEvent event) {
event.getX();
event.getY();
if (x >= 8 && y >= 8 && x <= 269 && y <= 269) {
rgbXSelect1 = Math.max(0, Math.min(255, x - 10));
rgbYSelect1 = Math.max(0, Math.min(255, y - 10));
Graphics g = getGraphics();
DrawBackground(g);
DrawSelector(g);
} else
if (x >= 275 && y >= 8 && x <= 286 && y <= 263) {
rgbYSelect2 = Math.max(0, Math.min(255, y - 10));
viewColor = new Color(pixels2[rgbYSelect2 * 10]);
MakeImageCanvas();
Graphics g = getGraphics();
DrawBackground(g);
} else {
return false;
}
return true;
}
Thanks nspils for the page and help!
-Crawf
crawf at 2007-11-11 22:35:16 >
