DJ-Raven / swing-glasspane-popup

Java swing UI popup dialog custom using glasspane
MIT License
25 stars 8 forks source link

Using GlassPanePopup.install(this); in multi JFrames constructors #4

Closed mad960 closed 1 week ago

mad960 commented 1 week ago

While I am using MessageAlerts.getInstance().showMessage() as confirm dialog in many buttons and operation and many JFrames, I faced recently a problem when working in more than JFrame at the same time. The problem is the confirm dialog does not appear in the JFrame I am using because it previously appeared on another JFrame, I tried to use GlassPanePopup.install(this); in some window events like focus gained and activated but also did not work and gives me run errors in miglayout, the initialization just works in constructors for some reason. I embed directly the project's code and tried to solve it, while I couldn't, I suggest the next update to be non-static, like each JFrame will have its own GlassPanePopup and use install in constructor, and also we could pass the local GlassPanePopup to MessageAlerts.getInstance().showMessage(), I tried to edit all the project code to use non-static variables, but I don't have much time, so I stopped and writing this issue, hoping to solve it as a new branch.

DJ-Raven commented 1 week ago

This glassPane popup do not support muti jframe install. but you can try modal dialog project here

this modal dialog project no need to install the frame

ModalDialog.showModal(this,
        new SimpleModalBorder(new JLabel("Sample message text"),
                "Message",
                SimpleModalBorder.YES_NO_OPTION,
                (controller, action) -> {
                    if (action == SimpleModalBorder.YES_OPTION) {
                        // yes option
                    }
                }));
mad960 commented 1 week ago

Thanks for fast responding, I am trying, it is animated like MessageAlerts.getInstance().showMessage()? If it is, can you please provide me an example of usage.

DJ-Raven commented 1 week ago

@mad960 here you can check my commit here and demo test class

2024-07-08_131304