简体   繁体   中英

How can I pass the parent to use in the JOptionPane that is inside a common method?

I have a JFrame with 2 buttons.

Each of the buttons displays a dialog specific to that button: JDialog A and JDialog B . Each of these dialogs use a class with method M. Inside Method M, I display a JOptionPane .

I tried passing the dialogs as components, but that did not work. I can't use null in the JOptionPane since I need it on top.

How can I pass the parent dialog ( A or B ) to be used in the JOptionPane ?

I was able to fix my problem by reviewing the comments, especially from @Radiodef. The problem was that my object was getting corrupted by another thread so it only worked if I did not pass the object and hard-coded it instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM