problem with run any import java.applet.Applet;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import javax.swing.JOptionPane;
/**
An applet that lets a user choose a color by specifying
the fractions of red, green, and blue.
*/
public class ColorApplet extends Applet
{
public ColorApplet()
{
String input;
// ask the user for red, green, blue values
input = JOptionPane.showInputDialog("red:");
float red = Float.parseFloat(input);
input = JOptionPane.showInputDialog("green:");
float green = Float.parseFloat(input);
input = JOptionPane.showInputDialog("blue:");
float blue = Float.parseFloat(input);
fillColor = new Color(red, green, blue);
}
public void paint(Graphics g)
{
Graphics2D g2 = (Graphics2D)g;
// select color into graphics context
g2.setColor(fillColor);
// construct and fill a square whose center is
// the center of the window
Comments
Leave a comment