import javax.swing.*;
import java.awt.*;
import java.awt.Color.*;
public class JStopSign extends JFrame implements MouseListener
{
public void paint(Graphics g)
{
super.paint(g);
//Define coordinates of outer polygon (edge of sign) and
//inner polygon(red portion)
int[] xOuter = {56, 107, 143, 143, 107, 56, 20, 20};
int[] yOuter = {40, 40, 76, 127, 163, 163, 127, 76};
int[] xInner = {57, 106, 138, 138, 106, 57, 25, 25};
int[] yInner = {45, 45, 77, 126, 158, 158, 126, 77};
// Draw edge of sign in black
g.setColor(Color.black);
g.drawPolygon(xOuter, yOuter, xOuter.length);
//Fill inerior if sign with red
public void mouseEntered(MouseEvent me)
{
g.setColor(Color.red);
g.fillPolygon(xInner, yInner, xInner.length);
}
public void mouseExited(MouseEvent me)
{
}
//Display "STOP"in white
g.setColor(Color.white);
g.setFont(new Font("SansSerif", Font.BOLD, 36));
g.drawString("STOP", 33, 116);
//Define coordinates of outer polygon (edge of sign) and
//inner polygon(orange portion)
int[] aOuter = {56, 107, 143, 143, 107, 56, 20, 20};
int[] bOuter = {240, 240, 276, 327, 363, 363, 327, 276};
int[] aInner = {57, 106, 138, 138, 106, 57, 25, 25};
int[] bInner = {245, 245, 277, 326, 358, 358, 326, 277};
// Draw edge of sign in black
g.setColor(Color.black);
g.drawPolygon(aOuter, bOuter, aOuter.length);
//Fill inerior if sign with orange
public void mouseEntered(MouseEvent me)
{
g.setColor(Color.orange);
g.fillPolygon(aInner, bInner, aInner.length);
}
public void mouseExited(MouseEvent me)
{
}
//Display "READY"in white
g.setColor(Color.white);
g.setFont(new Font("SansSerif", Font.BOLD, 29));
g.drawString("READY", 33, 316);
//Define coordinates of outer polygon (edge of sign) and
//inner polygon(green portion)
int[] cOuter = {56, 107, 143, 143, 107, 56, 20, 20};
int[] dOuter = {440, 440, 476, 527, 563, 563, 527, 476};
int[] cInner = {57, 106, 138, 138, 106, 57, 25, 25};
int[] dInner = {445, 445, 477, 526, 558, 558, 526, 477};
// Draw edge of sign in black
g.setColor(Color.black);
g.drawPolygon(cOuter, dOuter, cOuter.length);
//Fill inerior if sign with green
public void mouseEntered(MouseEvent me)
{
g.setColor(Color.green);
g.fillPolygon(cInner, dInner, cInner.length);
}
public void mouseExited(MouseEvent me)
{
}
//Display "GO"in white
g.setColor(Color.white);
g.setFont(new Font("SansSerif", Font.BOLD, 50));
g.drawString("GO", 45, 516);
}
public static void main(String[] args)
{
JStopSign frame = new JStopSign();
frame.setSize(200, 600);
frame.setVisible(true);
addMouseListener(this);
addMouseMotionListener(this);
}
}