|
change colors
Hi,
I need to modify following program inorder to incoroporate colors by creating toolbar.Toolbar should have 6 radio buttons Red,Black,Magenta,Blue,Green & Yellow. When new color is seleted , drawing should occur in new color.
Thank you in advance
package guidemo1;
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import javax.swing.JFrame;
public class Painter
extends Applet{
private int xValue=-1, yValue=-10;
public void paint(Graphics g){
g.drawString("Drag the mouse to draw",10,20);
g.fillOval(xValue,yValue,4,4);
}
public void update(Graphics g){
paint(g);
}
public boolean mouseDrag(Event evtObj,int x,int y){
xValue=x;
yValue=y;
repaint();
return true;
}
}
|