A4_Solutions - import java.awt.*; import java.awt.event.*;...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; /** An instance of this class shows a color and its complement as well as sliders for the RGB, HSV, and CMYK color models. Changing any of the sliders changes the color (and the other sliders appropriately).*/ public class A4 implements ChangeListener { /** the JFrame that is the GUI. */ private JFrame jf= null; /** Panels that contain the color and its complement, and labels that contain information in them. */ JPanel image, compImage; JLabel imageLabel, compImageLabel; /** Below are sliders. In each constructor call, the first argument makes it a vertical slider. The next three arguments are the minimum value, maximum value, and initial value of the slider. /** RGB sliders. */ JSlider RSlider= new JSlider(JSlider.VERTICAL, 0, 25500, 25500); JSlider GSlider= new JSlider(JSlider.VERTICAL, 0, 25500, 0); JSlider BSlider= new JSlider(JSlider.VERTICAL, 0, 25500, 0); /** HSV sliders. */ JSlider HSlider= new JSlider(JSlider.VERTICAL, 0, 35999, 0); JSlider SSlider= new JSlider(JSlider.VERTICAL, 0, 100, 100); JSlider VSlider= new JSlider(JSlider.VERTICAL, 0, 100, 100); /** CMYK sliders. */ JSlider CSlider= new JSlider(JSlider.VERTICAL, 0, 100, 0); JSlider MSlider= new JSlider(JSlider.VERTICAL, 0, 100, 100); JSlider YSlider= new JSlider(JSlider.VERTICAL, 0, 100, 100); JSlider KSlider= new JSlider(JSlider.VERTICAL, 0, 100, 0); /** Create and show a GUI that contains: (0) a color panel, with text to describe the color. (1) the complementary color panel, with text to describe it. (2) Sliders for RGB, HSV, and CMYK. Initially, the color is red. */ public static void main(String args) { A4 a4= new A4(); } /** Constructor: a GUI that contains: (0) a color panel, with text to describe the color....
View Full Document

This homework help was uploaded on 02/20/2009 for the course CS 100 taught by Professor Fan/vanloan during the Spring '07 term at Cornell University (Engineering School).

Page1 / 5

A4_Solutions - import java.awt.*; import java.awt.event.*;...

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