I am working on the game, and in the process of creating the main menu, I ran into a problem:

There is a MMenu panel, on which is the Exit button. Clicking on Exit should display the CheckExit panel (which is also located on the MMenu panel) (CheckExit is a check of exit from the program, in the form of 2 "Back" and "Exit" buttons).

CheckExit is small in size and does not completely cover all elements of the MMenu panel, which allows you to point and click on the MMenu panel buttons that remain visible. When hovering, the buttons from the MMenu panel overlap the CheckExit panel.

The question is how to make the CheckExit panel with its contents appear on top of all elements and in no way overlap with other elements of the MMenu panel?

    1 answer 1

    You need to use JDialog or JOptionPane

    JOptionPane.showConfirmDialog(null, "Хотите выйти?", "Вы действительно хотите выйти из игры?", JOptionPane.YES_NO_OPTION); 
    • This is a solution to my current problem, but is not the answer to the question posed. In the future, I plan to use the imposition of some elements on others, and I would like to understand the positioning of elements in Swing. - TrueASL
    • Then you need to reformulate the question - Mikhail Vaysman
    • Reformulated. Now it’s more clear what I want to know? - TrueASL
    • @TrueASL If you have a new question, ask it using the “ Ask a Question ” button. If you need to specify the context, give a link to this question. - Mikhail Vaysman