viruswarning.java

来自「Java经典例程 从外国一大学计算机教授出版物下载的代码 经典」· Java 代码 · 共 42 行

JAVA
42
字号
import java.awt.*;
import java.awt.event.*;

class VirusWarning extends Frame {

    /* The Graphic warning Program    by J M Bishop Oct 1996
     *                         Java 1.1 by T Abbott Oct 1997
     *                         updated 1.2 by J Bishop May 2000
     * produces a warning message on the screen in cyan
     * and black.
     * Illustrates setting up a window, painting in it
     * and enabling the close box.
     */

    VirusWarning () {
      setTitle("Draw Warning");
      setSize(220,150);
      setBackground(Color.cyan);
      setForeground(Color.black);
      addWindowListener(new WindowAdapter () {
        public void windowClosing(WindowEvent e) {
          System.exit(0);
        }
      });
      setVisible(true);
    }

    public void paint(Graphics g) {
      g.setColor(Color.pink);
      g.fillRect(25, 30, 150, 90);
      g.setColor(Color.black);
      g.drawString("W A R N I N G",           70, 60);
      g.drawString("Possible virus detected", 45, 75);
      g.drawString("Reboot and run virus",    50, 90);
      g.drawString("remover software",        60, 105);
    }

    public static void main(String[] args) {
      new VirusWarning ();
    }
  }

⌨️ 快捷键说明

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