so I have a Board class that extends JPanel and method write that when called saves some coordinates and calls repaint. However, the effect of repaint is not displayed on screen. When I tried to add JLabel with redbackground to the panel it showed up, so the panel is showing, it's just that repaint does not work.
public int x, y;
public JPanel panel = new JPanel();
private int xx,yy;
private Color c;
public Board(int x, int y, int wolfNumber, int hareNumber){
this.x=x;
this.y=y;
wolvesCoords = new int[wolfNumber][2];
haresCoords = new int[hareNumber][2];
setLayout(new GridLayout());
add(panel);
}
public synchronized void write(int xx, int yy, Color c){
this.xx = xx;
this.yy = yy;
this.c = c;
repaint();
}
@Override
protected void paintComponent(Graphics g) {
int width=panel.getWidth()/x;
int height=panel.getHeight()/y;
g.setColor(c);
g.drawRect(xx*width, yy*height, width, height);
g.fillRect(xx*width, yy*height, width, height);
super.paintComponent(g);
}