To do
Define the mouseDown method in your applet, so
that you can position the starting point (ox=x, oy=y).
public boolean mouseDown(Event e, int x, int y){
ox=x; oy=y;
return true;
}
Find a way to change colors, eg:
public boolean mouseUp(Event e, int x, int y){
if(y>375){
if(x<25) g.setColor(Color.black);
else if(x<50) g.setColor(Color.white);
}
// (you might repaint the colorbuttons)
// repaint(0,375,400,25);
return true;
}
Draw the color selection buttons in the paint method:
public void paint(Graphics g){
g.setColor(Color.black);
g.fillRect(0,375,25,25);
g.setColor(Color.white);
g.fillRect(0,375,50,25);
return true;
}
Source.