Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why does my GUI disappear as soon as I initialize an ImageIcon?

So i wanna program a Tic Tac Toe game in java.

Now uppon clicking a button, i wanna set the Image of the Button to either "cross" or "circle", but as soon as a type following code, the buttons disappear until i hover over them, then they return.

ImageIcon cross = new ImageIcon("Cross.png");

What it looks like without the code above
What it looks like with the code above

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Project Structure here

>Solution :

I did in fact use null layot for the window

That’s the problem. For a 3 x 3 grid, I’d use a GridLayout. See How to Use GridLayout for further details.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading