我必须画没有线的正方形,而是在那一角画点 如果您要搜索更滑的拼图板,则可以找到更多
我尝试制作正方形
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class Puzzle extends JFrame {
private int x;
private int y;
public void paint(Graphics g){
super.paint(g);
g.setColor(Color.BLACK);
Graphics2D graphics2D = (Graphics2D) g;
//g.fillRect(0,0,100,100);
while(x<400) {
g.drawLine(x, 0, x, 400);
x += 20;
}
while(y<400) {
g.drawLine(0, y ,400,y);
y += 20;
}
}
public Puzzle(){
setSize(400,400);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
setLayout(new GridLayout());
}
public static void main(String[] args){
Puzzle puzzle = new Puzzle();
}
}
它看起来像更滑的拼图板