📄 drawnrectangle.java
字号:
import java.awt.*;
import java.io.Serializable;
public class DrawnRectangle extends DrawnShape implements Serializable{
static final long serialVersionUID =8706090001533630663L;
public DrawnRectangle(Color color, int x, int y) {
super(color, x, y, "draw rectangle");
}
protected DrawnRectangle(Color color, int x, int y, String text) {
super(color, x, y, text);
}
public void draw(Graphics g) {
int width = x2 > x1 ? x2 - x1 : x1 - x2;
int height = y2 > y1 ? y2 - y1 : y1 - y2;
g.setColor(color);
g.drawRect(Math.min(x1, x2), Math.min(y1, y2), width, height);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -