Re: JDialogs used with a Window



Damn-it! Google lost my entire 1st reply to that.

Here is the extremely abbreviated (and pissed-off) version..

<sscce>
import java.awt.event.*;
import javax.swing.*;

public class ModalOnWindow {

public static void main(String[] args) {
JWindow window = new JWindow();
JButton b = new JButton("Open Dialog");
b.addActionListener( new ActionListener() {
public void actionPerformed(ActionEvent ae) {
JDialog d = new JDialog();
d.getContentPane().add(new JLabel("Hi!"));
d.setModal(true);
d.pack();
d.setLocationRelativeTo(null);
d.setVisible(true);
}
});
window.getContentPane().add(b);
window.pack();
window.setSize( java.awt.Toolkit.
getDefaultToolkit().getScreenSize() );
window.setVisible(true);
}
}
</sscce>

This works.

Yours may not because you had the call to setVisible()
before adding the button. Moving it may fix the problem,
but otherwise please post a short, compilable example
of failing code.

Andrew T.

.