Hi,
I am trying to implement an applet.
The idea is to create the applet, then connect places where I single-click with the mouse with black lines until we give a double-click.
With a double-click I should clear the applet.
To clear the applet I am trying to set the color to white and re-draw all the lines so that I have a complete white screen.
The complete code is in attach.
Here is the specific code for the single/double clicks event:
public boolean mouseDown(Event evt, int x, int y)
{
// initialization
Graphics g = getGraphics();
// checks number of clicks
if (m_nNumMouseClicks < m_nMAXLOCS)
{
// checks for double click action
if ((lastX==x) && (lastY==y) && ((evt.when-timeMouseDown) < dClkRes))
{
System.out.println("double click: CLEAR SCREEN!!!");
// set color a white
g.setColor(Color.WHITE);
// print the lines in white to hide the black lines
for (int i = 0; i < m_nNumMouseClicks - 1; i++)
{
for (int j = i + 1; j < m_nNumMouseClicks; j++)
{
g.drawLine(m_dimLocs[i].width,
m_dimLocs[i].height,
m_dimLocs[j].width,
m_dimLocs[j].height);
}
}
// white squre
//g.fillRect(0, 0, 400, 400);
repaint();
return false;
}
// single click action
else
{
System.out.println("simple click");
timeMouseDown = evt.when;
lastX=x;
lastY=y;
// record the click location (if there's enough room)
m_dimLocs[m_nNumMouseClicks] = new Dimension(x, y);
m_nNumMouseClicks++;
// now force the window to repaint
repaint();
}
}
return true;
}
I appreciate your help, cheers,