ColorChooserApplet

ColorChooserApplet - A ColorChooserApplet shows six scroll...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
/* A ColorChooserApplet shows six scroll bars that the user can manipulate to set the red, gree, blue, hue, brightness, and saturation components of a color. A color patch shows the selected color, and there are six labels that show the numerical values of all the components. RGB components are specified as integers in the range 0 to 255. HSB components are specified as float values in the range 0.0F to 1.0F. */ * import java.awt.*; import java.awt.event.*; import java.applet.*; i public class ColorChooserApplet extends Applet implements AdjustmentListener { p private float[] hsb = new float[3]; // For holding HSB color components. private int r = 0, g = 0, b = 0; // The RGB color components. private Scrollbar hueScroll, brightnessScroll, saturationScroll, // Scroll bars. redScroll, greenScroll, blueScroll; private Label hueLabel, brightnessLabel, saturationLabel, // Display component values. redLabel, greenLabel, blueLabel; private Canvas colorCanvas; // Color patch for displaying the color. public void init() { Color.RGBtoHSB(0,0,0,hsb); // Get HSB equivalent of RGB = (0,0,0); /* Create Scrollbars with possible values from 0 to 255. */ hueScroll = new Scrollbar(Scrollbar.HORIZONTAL, (int)(255*hsb[0]), 10, 0, 265); saturationScroll = new Scrollbar(Scrollbar.HORIZONTAL, (int)(255*hsb[1]), 10, 0, 265); brightnessScroll = new Scrollbar(Scrollbar.HORIZONTAL, (int)(255*hsb[2]),
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 3

ColorChooserApplet - A ColorChooserApplet shows six scroll...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online