Skip to content

Instantly share code, notes, and snippets.

@jimmykurian
Created February 3, 2012 21:54
Show Gist options
  • Save jimmykurian/1732923 to your computer and use it in GitHub Desktop.
Save jimmykurian/1732923 to your computer and use it in GitHub Desktop.
A Java program that draws the Olympic rings. The other program displays the Olympic rings.
//OlympicRingComponent.java - Jimmy Kurian
import javax.swing.JComponent;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Color;
public class OlympicRingComponent extends JComponent
{
public void paintComponent(Graphics g)
{
Graphics2D g2 = (Graphics2D) g;
g.drawOval (1,0,40,40);
g.setColor(Color.YELLOW);
g.drawOval (21,20,40,40);
g.setColor(Color.BLACK);
g.drawOval (41,0,40,40);
g.setColor(Color.GREEN);
g.drawOval (61,20,40,40);
g.setColor(Color.RED);
g.drawOval (81,0,40,40);
g.setColor(Color.BLUE);
}
}
//OlympicRingViewer.java - Jimmy Kurian
import javax.swing.JFrame;
public class OlympicRingViewer
{
public static void main(String[] args)
{
JFrame frame = new JFrame();
final int FRAME_WIDTH = 300;
final int FRAME_HEIGHT = 230;
frame.setSize(300, 230);
frame.setTitle("OlympicRingViewer");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
OlympicRingComponent component = new OlympicRingComponent();
frame.add(component);
frame.setVisible(true);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment