Thread: change colors
View Single Post
  #1 (permalink)  
Old 12-02-2007, 12:27 PM
calblue calblue is offline
Member
 
Join Date: Dec 2007
Posts: 1
calblue is on a distinguished road
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;
}

}
Reply With Quote
Sponsored Links