76 984
Assignments Done
Successfully Done
In June 2019

Answer to Question #23028 in Java | JSP | JSF for ahmad

Question #23028
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


// construct and fill a square whose center is
// the center of the window

Rectangle square = new Rectangle(
(getWidth() - SQUARE_LENGTH) / 2,
(getHeight() - SQUARE_LENGTH) / 2,
Expert's answer

Not answered

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions