开发者

Java Swing: JInternalFrame: need a dialog popup

开发者 https://www.devze.com 2022-12-10 16:18 出处:网络
I have a JInternalFra开发者_高级运维me window that needs to popup a modal dialog box when a JButton is pressed. At first, I tried using JDialog, but I found that JDialog constructor needs:

I have a JInternalFra开发者_高级运维me window that needs to popup a modal dialog box when a JButton is pressed. At first, I tried using JDialog, but I found that JDialog constructor needs:

  1. JFrame
  2. boolean modal

I tried passing JInternalFrame to it, but the type didn't match.

Should I use JDialog with JInternalFrame? What if I dont specify the owner (i.e. passing a null)? Is there anything wrong with that?


SwingUtilities.getAncestorOfClass(Window.class, myButton)

The abvove method will return the Window that contains your button. Once you have it you can pass it to the constructor of the dialog :)

EDIT1: I misread the question I guess. How can you have a JinternalFrame as the topmost window??

EDIT2: Also if you pass null to Jdialog constrcutor then by default it uses a shared owner i.e SwingUtilities.getSharedOwnerFrame()

0

精彩评论

暂无评论...
验证码 换一张
取 消