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

📄 test.java

📁 《Java2图形设计卷II:Swing》配套光盘源码
💻 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 + -