⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xorexam.java

📁 Java程序设计实用教程源代码 本书源代码按章分别放置在不同的文件夹中,所有程序均在JDK1.6环境下编译运行正常,除了第13章需要建立ODBC数据源之外,其他程序只要有Java运行环境即可直接运行
💻 JAVA
字号:
import java.awt.*;
import javax.swing.*;
public class xorExam extends JFrame {
  public xorExam() {
    super("XOR绘图模式");
    setSize(340, 240);
    setVisible(true);
  }
  public void paint(Graphics g) {
    super.paint(g);
    g.setColor(Color.BLUE);
    int xValues[] = {122, 100, 28, 86, 64, 122, 180, 158, 217, 144};
    int yValues[] = {56, 122, 122, 164, 230, 190, 230, 164, 123, 122};
    Polygon polygon1 = new Polygon(xValues, yValues, 10);
    g.fillPolygon(polygon1);
    g.setXORMode(Color.GREEN);
    int xValues2[] = {226, 204, 130, 190, 168, 226, 284, 262, 321, 248};
    int yValues2[] = {56, 123, 123, 165, 231, 191, 231, 165, 123, 123};
    Polygon polygon2 = new Polygon(xValues2, yValues2, 10);
    g.fillPolygon(polygon2);
    g.setXORMode(Color.MAGENTA);
    for (int i = 80; i < 180; i++) {
      g.fillOval(10 + i, 40, 80, 80);
      g.fillOval(10 + i + 1, 40, 80, 80);
    }
  }
  public static void main(String args[]) {
    xorExam app = new xorExam();
    app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  }
}

⌨️ 快捷键说明

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