📄 board.java
字号:
package client;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.GridLayout;
import javax.swing.JPanel;
public class Board extends JPanel {
private static final long serialVersionUID = 1L;
private int row;
private int col;
public Board(int row, int col) {
this.row = row;
this.col = col;
this.setBackground(Color.white);
setLayout(new GridLayout(row, col, 0, 0));
}
protected void paintComponent(Graphics g) {
super.paintComponent(g);
int width = getWidth();
int height = getHeight();
// draw Rectangle
g.setColor(Color.black);
g.drawRect(0, 0, width - 1, height - 1);
// draw line
for (int i = 0; i < row - 1; i++) {
g.drawLine(0, height / row * (i + 1), width, height / row * (i + 1));
}
for (int j = 0; j < col - 1; j++) {
g.drawLine(width / col * (j + 1), 0, width / col * (j + 1), height);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -