Now, I have a panel and a menu in the game. The panel is responsible for drawing the game board.
This is the initial state of the game:
http://up351.siz.co....4io2gdnyygw.png
(The image was uploaded on an Israeli server so in case it doesn't work, let me know, and I'll upload it to a different server).
Now, as soon as I make a move in the game, the board is repainting itself, and this is where the problem occurs.
When I repaint the panel, using the repaint method, the entire window is changing to the following state:
http://up351.siz.co....amfzjtzmnkg.png
When I change the size of the window, it will get better, but if I make a move again, the display will be ruined again.
Here's the code of the main window, which includes the menu and the panel:
import javax.swing.*;
public class Main extends JFrame {
private static final long serialVersionUID = 1L;
GameManager manager;
public static void main(String[] args) {
new Main();
}
public void initVariables() {
manager = new GameManager();
}
public void initFrame() {
this.setSize(480, 480);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JMenuBar menuBar = new JMenuBar();
JMenu menu1 = new JMenu("File");
menuBar.add(menu1);
this.setJMenuBar(menuBar);
this.add(manager.getDisplay());
this.setVisible(true);
}
public Main() {
super("Paradux by BaraCK Levy");
initVariables();
initFrame();
}
}If you need the rest of the classes, just let me know.Inside the GameManager class, there's a member called display of the type Display which extends JPanel.
Another strange situation that involves it is that if I press the File menu, and then exit the menu, the entire "New" menu item becomes the display. :SSS
Here are images of the situation:
http://up351.siz.co....jkyu2c2mwzy.png
http://up351.siz.co....tytjohjymfy.png
When I click on a tiny square on the game board on the upper left, the big game board is effected, a move is made, and the first problem occurs.
What's going on? It's like the panel is becoming the menu or something... Help me please. ;D


Sign In
Create Account


Back to top









