Bringing a Custom Swing Component to Life
I am sometimes down on the Java documentation, but in the sand plains of lugubrious and often confusing material there is the occasional gem. One example is a lesson from The Java Tutorial entitled Performing Custom Painting . I was directed to it by a reply to this thread in the Oracle Java Desktop forum . When I first began my efforts to create a rainbow colored Gaussian distribution curve I began with one of the Tutorial lessons on colors. I have unfortunately lost the URL for the lesson but the code began something like this: import java.awt.Color; import java.awt.Graphics; import java.awt.Graphics2D; import javax.swing.JFrame; import javax.swing.JPanel; public class Colors extends JPanel { public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2d = (Graphics2D) g; g2d.setColor(new Color(255, 0, 0));//vivid red g2d.fillRect(10, 15, 90, 60); ... } public static void main(String[] args) { JFrame frame = new JFrame("Colors"); frame.s...