📄 mybox.java
字号:
import javax.microedition.lcdui.Graphics;
class MyBox
{
public int left = 0;
public int top = 0;
public int right = 10;
public int bottom = 10;
public int width = 10;
public int height = 10;
public int xCenter;
public int yCenter;
public boolean bVisible = true;
public void MyBox()
{
this.left = (this.top = 0);
this.right = (this.bottom = this.width = this.height = 0);
adjustCenter();
}
public void setWidthHeight(int paramInt1, int paramInt2)
{
this.width = paramInt1;
this.right = (this.left + this.width);
this.height = paramInt2;
this.bottom = (this.top + this.height);
adjustCenter();
}
public void adjustCenter()
{
this.xCenter = (this.left + this.width / 2);
this.yCenter = (this.top + this.height / 2);
}
public boolean isInTheBox(int paramInt1, int paramInt2)
{
return ((paramInt1 >= this.left) && (paramInt1 <= this.right) && (paramInt2 >= this.top) && (paramInt2 <= this.bottom));
}
public boolean isAbove(int paramInt)
{
return (paramInt > this.top);
}
public boolean isBelow(int paramInt)
{
return (paramInt < this.bottom);
}
public boolean isOnLeftSide(int paramInt)
{
return (paramInt < this.left);
}
public boolean isOnRightSide(int paramInt)
{
return (paramInt > this.right);
}
public void move(int paramInt1, int paramInt2)
{
this.left += paramInt1;
this.right += paramInt1;
this.top += paramInt2;
this.bottom += paramInt2;
adjustCenter();
}
public void moveHorizontal(int paramInt)
{
this.left += paramInt;
this.right += paramInt;
adjustCenter();
}
public void moveVertical(int paramInt)
{
this.top += paramInt;
this.bottom += paramInt;
adjustCenter();
}
public void fillRect_white(Graphics paramGraphics)
{
fillRect(paramGraphics, 255, 255, 255);
}
public void fillRect_black(Graphics paramGraphics)
{
fillRect(paramGraphics, 0, 0, 0);
}
public void fillRect(Graphics paramGraphics, int paramInt1, int paramInt2, int paramInt3)
{
paramGraphics.setColor(paramInt1, paramInt2, paramInt3);
paramGraphics.fillRect(this.left, this.top, this.width, this.height);
}
public void drawRect(Graphics paramGraphics, int paramInt1, int paramInt2, int paramInt3)
{
paramGraphics.setColor(paramInt1, paramInt2, paramInt3);
paramGraphics.drawRect(this.left, this.top, this.width, this.height);
}
public void drawRect(Graphics paramGraphics)
{
paramGraphics.drawRect(this.left, this.top, this.width, this.height);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -