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

📄 nestedrects.java

📁 书籍"Java_面向事件编程"的附带光盘代码
💻 JAVA
字号:
import objectdraw.*;import java.awt.*;// Recursive structure for collection of nested rectanglespublic class NestedRects implements NestedRectsIfc {    private FramedRect outerRect;   // outermost rectangle in picture    private NestedRectsIfc rest;    // remaining nested rectangles        public NestedRects(double x, double y, double width, double height,                        DrawingCanvas canvas) {        outerRect = new FramedRect(x, y, width, height, canvas);        if (width >= 8 && height >= 8) {            rest = new NestedRects( x + 4, y + 4, width - 8,                                    height - 8, canvas);        } else {       // construct a base object            rest = new BaseRects();        }    }        // move nested rectangles to (x,y)    public void moveTo(double x, double y) {        outerRect.moveTo(x, y);        rest.moveTo(x + 4, y + 4);    }        // remove the nested rectangles from the canvas    public void removeFromCanvas() {        outerRect.removeFromCanvas();        rest.removeFromCanvas();    }}

⌨️ 快捷键说明

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