📄 xorexam.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 + -