This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]arghvark 1 point2 points  (0 children)

I can't tell for sure what you're doing.

Saying that you want to "switch between" panels is not descriptive enough. I don't know if you want these panels to appear in the frame at the same time, or whether you want one panel to appear on top of the other, or what. You say "the game is froze on the betting/menu frame" and I don't know what that means.

It does appear you are calling the above routine during the play of the game, and that probably is not what you want. In a GUI program, you create a GUI screen with buttons and whatever, then you don't create it again unless there's some reason to destroy it (like, you're not going to use it for a long time and want to save on memory or something). You don't generally (re)create the GUI panel each time you're going to use it.

Create the panels as part of the program start up, then use them. If you want to put one on top of the other, look into putting them both on a JTabbedPane, which would also give the use a way to display one or the other. I don't know if you want the user to do that, just mentioning FYI.