Ok, so something like this?
import java.applet.Applet;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Paint;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.JPanel;
public class Drawing extends Applet implements MouseListener{
[B]public void init() {
this.addMouseListener(this);
if(this.mouseClicked(this))
{
x=getX();
y=getY();
drawRedBlock = true;
}[/B]
}
private boolean mouseClicked(Drawing drawing) {
return false;
}
boolean drawRedBlock = false;
int x = 0;
int y = 0;
public void paint(Graphics g){
g.setColor(Color.white);
g.fillRect(0,0,500,500);
g.setColor(Color.black);
g.drawLine(0,0,500,0);
g.drawLine(500,500,500,0);
g.drawLine(500,500,0,500);
g.drawLine(0,500,0,0);
g.setColor(Color.red);
g.fillRect(125,125,125,125);
}
public void drawRedBlock(Graphics g){
if(drawRedBlock=true)
{
g.setColor(Color.red);
g.fillRect(x, y, 125, 125);
repaint();
}
}
public void mouseEntered(MouseEvent arg0) {}
public void mouseExited(MouseEvent arg0) {}
public void mousePressed(MouseEvent arg0) {}
public void mouseReleased(MouseEvent arg0) {}
public void keyPressed(KeyEvent e) {}
public void keyReleased(KeyEvent e) {}
public void keyTyped(KeyEvent e) {}
@Override
public void mouseClicked(MouseEvent e) {
// TODO Auto-generated method stub
}
}