📄 test.java
字号:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Test extends JApplet {
Rectangle r1 = new Rectangle(20,20,150,75);
Rectangle r2 = new Rectangle(100,40,100,150);
Rectangle destination;
public Test() {
destination = new Rectangle(r2);
// print out the intersection of r1 and r2 ...
System.out.println("Intersection: " +
SwingUtilities.computeIntersection(r1.x,r1.y,
r1.width,r1.height,destination));
System.out.println();
// print out the union of r1 and r2 ...
System.out.println("Union: " +
SwingUtilities.computeUnion(r1.x,r1.y,
r1.width,r1.height,destination));
System.out.println();
// print out the difference of r1 and r2 ...
Rectangle[] difference =
SwingUtilities.computeDifference(r1, r2);
System.out.println("Difference:");
for(int i=0; i < difference.length; ++i) {
System.out.println(difference[i]);
}
}
public void paint(Graphics g) {
g.setColor(Color.red);
g.fillRect(r1.x, r1.y, r1.width, r1.height);
g.setColor(Color.yellow);
g.fillRect(r2.x, r2.y, r2.width, r2.height);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -