stopsign.java

来自「java语言与面向对象程序设计源程序」· Java 代码 · 共 21 行

JAVA
21
字号
import java.awt.*;
public class StopSign extends Canvas
{  private final static int[] X = {10,20,30,30,20,10, 0, 0};
   private final static int[] Y = { 0, 0,10,20,30,30,20,10};
   private final static Polygon P = new Polygon(X,Y,X.length);
   private final static Color FILL_COLOR = new Color(200,0,0);
   public StopSign ()
   {  super();
      setBackground(Color.lightGray);
   }
   public Dimension getPreferredSize()
   {  return new Dimension(32,32); }
   public void paint(Graphics g)
   {  g.setColor(FILL_COLOR);
      g.fillPolygon(P);
      g.setColor(Color.black);
      g.drawPolygon(P);
   }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?