?? gamepanel.java
字號(hào):
package com.zhanggang.teris.view;
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JPanel;
import com.zhang.teris.util.Global;
import com.zhanggang.teris.entities.Ground;
import com.zhanggang.teris.entities.Shape;
public class GamePanel extends JPanel {
Ground ground;
Shape shape;
public void display(Ground ground, Shape shape) {
System.out.println("GamePanel's display");
this.ground = ground;
this.shape = shape;
repaint();
}
@Override
protected void paintComponent(Graphics g) {
Color c = g.getColor();
g.setColor(new Color(0xb2b2bf));
g.fillRect(0, 0, this.getWidth(), this.getHeight());
g.setColor(c);
if(ground != null && shape != null) {
ground.drawMe(g);
shape.drawMe(g);
}
}
public GamePanel() {
setSize(Global.WIDTH * Global.CELL_SIZE, Global.HEIGHT * Global.CELL_SIZE);
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -