I developed two JFrames in NetBeans.
When I click the "rules" button (that is, it is located on JFrame1), it opens a second JFrame (but JFrame2 opens in JFrame1, which I don’t want). The second JFrame has a close button. But when I click this button, I want JFrame1 to be open and it works too, but JFrame2 is not actually closed and JFrame1 appears above JFrame2.
In short, the main form is JFrame1. When I click the "rules" button from JFrame1, it opens JFrame2 above JFrame1, and the "close" button appears in JFrame2, when clicked, the main form (for example, JFrame1) is called but launched through JFrame2.
The script is JFframe1 → JFrame2 → JFrame1
Now my question is - after clicking the "rules" button, JFrame1 should be closed and JFrame2 displayed on the screen and vice versa.
source share