This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
[PATCH] Fix and Improve TestAWT program
- From: Fernando Nasser <fnasser at redhat dot com>
- To: GCJ Patches <java-patches at gcc dot gnu dot org>
- Date: Mon, 12 Jan 2004 22:14:08 -0500
- Subject: [PATCH] Fix and Improve TestAWT program
- Organization: Red Hat Canada
The TestAWT program was calling both setVisible() and show() which
caused modal dialogs to be shown twice (both with libgcj and with Sun
JRE). It is now fixed.
I've also added a button so a second level (or Nth level) modal dialog
can be created from the currently show modal dialog.
I need this to show why some of my following patches to EventQueue.java
are necessary. With the new test one can verify that a modal dialog
shown from a modal dialog still doesn't work.
The good news is that I have the fix.
2004-01-12 Fernando Nasser <fnasser@redhat.com>
* gnu/java/awt/peer/gtk/TestAWT.java: Fix test program so that
it does
not show modal dialogs twice and so that it allows showing a modal
dialog from another modal dialog.
--
Fernando Nasser
Red Hat Canada Ltd. E-Mail: fnasser@redhat.com
2323 Yonge Street, Suite #300
Toronto, Ontario M4P 2C9
Index: gnu/java/awt/peer/gtk/TestAWT.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/java/awt/peer/gtk/TestAWT.java,v
retrieving revision 1.1
diff -c -p -r1.1 TestAWT.java
*** gnu/java/awt/peer/gtk/TestAWT.java 31 Jan 2003 17:54:13 -0000 1.1
--- gnu/java/awt/peer/gtk/TestAWT.java 13 Jan 2004 03:06:07 -0000
*************** class MainWindow extends PrettyFrame imp
*** 184,191 ****
w.dispose ();
else
{
! w.setVisible (true);
! w.show();
}
}
}
--- 184,199 ----
w.dispose ();
else
{
! if (w instanceof Dialog)
! {
! System.out.println ("Will 'show'");
! w.show();
! System.out.println ("Has shown");
! }
! else
! {
! w.setVisible (true);
! }
}
}
}
*************** class ButtonsWindow extends SubFrame imp
*** 250,260 ****
--- 258,271 ----
class DialogWindow extends Dialog implements SubWindow
{
Label text;
+ Frame parent;
boolean initted = false;
public DialogWindow (Frame f)
{
super (f, true);
+
+ this.parent = f;
}
public void setVisible (boolean visible)
*************** class DialogWindow extends Dialog implem
*** 264,269 ****
--- 275,287 ----
super.setVisible (visible);
}
+ public void show ()
+ {
+ if (!initted)
+ init();
+ super.show ();
+ }
+
public void init ()
{
text = new Label ("Dialog Test");
*************** class DialogWindow extends Dialog implem
*** 282,288 ****
}
});
! p.setLayout (new GridLayout (1, 2));
((GridLayout) p.getLayout ()).setHgap (5);
((GridLayout) p.getLayout ()).setVgap (5);
p.add (cb);
--- 300,306 ----
}
});
! p.setLayout (new GridLayout (1, 3));
((GridLayout) p.getLayout ()).setHgap (5);
((GridLayout) p.getLayout ()).setVgap (5);
p.add (cb);
*************** class DialogWindow extends Dialog implem
*** 300,309 ****
doLayout();
}
});
add (p, "South");
setTitle ("Dialog");
! setSize (130, 70);
}
}
--- 318,340 ----
doLayout();
}
});
+
+ Button subdlg = new Button ("SubDialog");
+ p.add (subdlg);
+
+ subdlg.addActionListener(new ActionListener () {
+ public void actionPerformed (ActionEvent e)
+ {
+ DialogWindow sw = new DialogWindow (parent);
+ System.out.println ("Will show modal sub dialog");
+ sw.show ();
+ System.out.println ("Has shown modal sub dialog");
+ }
+ });
add (p, "South");
setTitle ("Dialog");
! setSize (240, 120);
}
}