I believe that I've discovered a bug in how a window manager deals with JDialogs. Briefly, if I create a JFrame and a number of JDialogs that are owned by it, JDialogs that are made visible before the JFrame is made
visible perform correctly in that calling their toFront methods and their
setResizable(true) methods work as they should. JDialogs that are made visible after the owning JFrame has been made visisble do not perform as they should: calling their toFront methods does not bring them to the front of other windows, and calling setResizable(true) before the JDialogs
are displaye does not make them resizable. I believe that this is a problem with the window manager because I do not have the problem with Gnome, KDE or Xfce (or MS Windows - but that's not blackdown). I do have the problem with fluxbox and with Mac OS X (and, that's not blackdown either). I'd like to report the problem to the developers of flux box and Mac OS X, and I'd like to be able to say something besides Java JDialogs
don't work as they should.


Does anyone who has experience developing Java for X have an idea of what's wrong on the X side so that I can give the developers something more than JDialogs don't work as the should? My fear is that if the developers don't know how java works they may not know where to look.

Thanks,

Dick

P.S. Below is a program that demonstrates the problem. It generates 5 JDialogs that are owned by a JFrame. The menu can be used to select the
JDialog that should be at the front. It works for A and B, but not for C, D, and E. Also, note that JDialogs A and B are resizable and that C, D and E are not.


import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;

public class JToFrontDemo extends JFrame {

        JMenu    the_menu = new JMenu("MENU");

        public static void main(String[] argv) {
                JToFrontDemo demo = new JToFrontDemo("JToFrontDemo");
                JDialog da = demo.addJDialog("Dialog A");
                JDialog db = demo.addJDialog("Dialog B");
                JDialog dc = demo.addJDialog("Dialog C");
                JDialog dd = demo.addJDialog("Dialog D");
                JDialog de = demo.addJDialog("Dialog E");
                // if demo.setVisible(true) were here nothing would work!
                da.setVisible(true);
                db.setVisible(true);
                demo.setVisible(true);
                dc.setVisible(true);
                dd.setVisible(true);
                de.setVisible(true);
                // if demo.setVisible(true) were here everything would work!
        }

        public JToFrontDemo(String title) {
                super(title);
                JMenuBar menubar = new JMenuBar();
                menubar.add(the_menu);
                setJMenuBar(menubar);
                getContentPane().add(new JLabel("THE FRAME"));
                pack();
                addWindowListener(new WindowAdapter() {
                        public void windowClosing(WindowEvent we) {
                                System.exit(0);
                        }
                });
        }

        public JDialog addJDialog(String label) {
                JDialog adialog = new JDialog(this, label);
                adialog.getContentPane().add(new JLabel(label));
                JMenuItem jmi = new JMenuItem(label);
                jmi.addActionListener(new ML(adialog));
                the_menu.add(jmi);
                adialog.setLocation(100, 100);
                adialog.setResizable(true);
                adialog.pack();
                return adialog;
        }

        private class ML implements ActionListener {
                private JDialog the_dialog;
                public ML(JDialog adialog) {
                        the_dialog = adialog;
                }
                public void actionPerformed(ActionEvent e) {
                        the_dialog.toFront();
                }
        }

}


---------------------------------------------------------------------- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Reply via email to