import java.awt.*; import javax.swing.*; /* */ public class Graph extends JApplet { @Override public void paint(Graphics g) { super.paint(g); int[] is = {10, 4, 6, 2, 9, 1}; Color[] cs = {Color.RED, Color.BLUE}; int scale = 15; int i, n = is.length; for (i = 0; i < n; i++) { g.setColor(cs[i % cs.length]); g.fillRect(0, i * scale, is[i] * scale, scale); } } public static void main(String[] args) { JFrame frame = new JFrame(""); JApplet applet = new Graph(); applet.setPreferredSize(new Dimension(200, 100)); frame.add(applet); frame.pack(); frame.setVisible(true); applet.init(); applet.start(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } }