rectangle.java
来自「java语言实现的一个画图小程序,可以实现绘图」· Java 代码 · 共 44 行
JAVA
44 行
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package drawfigure;import java.awt.Color;class Rectangle extends Shape{//矩形类,继承了正方形类 public Rectangle(){} public Rectangle(int sx,int sy,int x,int y,Color c,boolean f){ super(sx,sy,x,y,c);fill=f;i=3; } void setValue(int sx,int sy,int x,int y,Color c,boolean f){ super.setValue(sx,sy,x,y,c);fill=f;i=3; } @Override void draw(){ x0=x>sx?sx:x;y0=y>sy?sy:y; g.setColor(c); g.setPaintMode(); if(!fill) { g.drawRect(x0,y0,Math.abs(x-sx),Math.abs(y-sy)); } else { g.fillRect(x0,y0,Math.abs(x-sx),Math.abs(y-sy)); } } @Override void wipe() { x0=x>sx?sx:x;y0=y>sy?sy:y; g.setXORMode(back); if(!fill) { g.drawRect(x0,y0,Math.abs(x-sx),Math.abs(y-sy)); } else { g.fillRect(x0,y0,Math.abs(x-sx),Math.abs(y-sy)); } }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?