Rowley4
asked on
How do I use a graphics program to draw 12 strings, one for each standard color (not including white) each in its own color.
How do I use a graphics program to draw 12 strings, one for each standard color (not including white) each in its own color. Here are my two classes I started. Please, I am stuck form here.
import javax.swing.JFrame;
/**
Shows frame with the standard color names.
*/
public class ColorNameViewer
{
public static void main(String[] args)
{
JFrame frame = new JFrame();
frame.setSize(300, 400);
frame.setTitle("ColorNameViewer");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
ColorNameComponent component = new ColorNameComponent();
frame.add(component);
frame.setVisible(true);
}
}
import javax.swing.JComponent;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
public class ColorNameComponent extends JComponent
{
public void paintComponent(Graphics g)
{
Graphics2D g2 = (Graphics2D) g;
. . .
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This is GREAT!! Thank you SOO much!
No problem! Glad you like it :-)
g2.draw(new Line2D.Double(i, 0, i, 10));
format: x1, y1, x2, y2