myrect.java

来自「创建一些形状类」· Java 代码 · 共 79 行

JAVA
79
字号
/*  * File name: MyRect.java * * This file defines a MyRect class. * * Author: R. R. Gargeya * Date:   12 March 2000 * * Distribution: This header should always be included. */import java.awt.Graphics;public class MyRect{    private int x, y, width, height;    public MyRect()    {	x = 0;	y = 0;	width = 0;	height = 0;    }    public MyRect(int x, int y, int width, int height)    {	this.x = x;	this.y = y;	this.width = width;	this.height = height;    }        public void setX(int x)    {	this.x = x;    }    public void setY(int y)    {	this.y = y;    }    public void setWidth(int width)    {	this.width = width;    }    public void setHeight(int height)    {	this.height = height;    }    public int getX()    {	return x;    }    public int getY()    {	return y;    }    public int getWidth()    {	return width;    }    public int getHeight()    {	return height;    }    public void draw(Graphics g)    {	g.drawRect(x, y, width, height);    }}

⌨️ 快捷键说明

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