像下面这段代码,最小化frame时dialog也看不到了
final JFrame frame = new JFrame("Example");
frame.setBounds(200,200,600,400);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
final JDialog dialog = new JDialog(frame, "Setting");
dialog.setPreferredSize(new Dimension(300,200));
dialog.setLocationRelativeTo(frame);
dialog.pack();
final JButton button = new JButton("Show Setting Dialog");
button.addActionListener(new ActionListener(){
@Override public void actionPerformed(ActionEvent e){
dialog.setVisible(true);
}
});
frame.add(button, BorderLayout.PAGE_START);
frame.setVisible(true);