rectangle.java
来自「Java程序设计(美) David D. Riley著 机械工业出版社 书籍配套」· Java 代码 · 共 31 行
JAVA
31 行
import javax.swing.*;import java.awt.*;/** Rectangle Supplier Class * Author: David D. Riley * Date: April, 2004 */public class Rectangle extends JComponent { /** post: getX() == x and getY() == y * and getWidth() == w and getHeight() == h * and getBackground() == Color.black */ public Rectangle(int x, int y, int w, int h) { super(); setBounds(x, y, w, h); setBackground(Color.black); } /** post: this method draws a filled Rectangle * and the upper left corner is (getX(), getY()) * and the rectangle's dimensions are getWidth() and getHeight() * and the rectangle's color is getBackground() */ public void paint(Graphics g) { g.setColor( getBackground() ); g.fillRect(0, 0, getWidth()-1, getHeight()-1); paintChildren(g); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?