📄 grectangle.java
字号:
import java.awt.*;
/** Class to construct a single rectangle
*/
public class GRectangle
{
private int xCoord, yCoord;
private int width, height;
private Color choice;
/** creates rectangle with given position, dimensions and colour
* @param initHeight Vertical dimension of rectangle
* @param initX x coordinate of top left hand corner
* @param initY y coordinate of top left hand corner
* @param initWidth Horizontal dimension of rectangle
* @param initColor colour of rectangle
*/
public GRectangle(int initX, int initY, int initWidth, int initHeight, Color initColor)
{
xCoord = initX;
yCoord = initY;
width = initWidth;
height = initHeight;
choice = initColor;
}
public void displayLine(Graphics g)
{
g.setColor (choice);
g.drawRect(xCoord, yCoord, width, height);
}
public void displayOutline(Graphics g)
{
g.setColor (choice);
g.drawRect(xCoord, yCoord, width, height);
}
/** displays a rectangle filled in a given colour
* @param g the graphics object of the frame
*/
public void displayFilled (Graphics g)
{
g.setColor(choice);
g.fillRect(xCoord, yCoord, width, height);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -