-
Bug
-
Resolution: Fixed
-
P2
-
1.1.4, 1.1.5, 1.2.0
-
swing1.0fcs
-
generic, x86
-
generic, windows_95, windows_nt
-
Verified
cah filed for PeopleSoft as bugid 4098472 which was closed
as duplicate of 4093188. It was incorrectly closed as a duplicate
and am resubmitting as suggested by engineering.
ere is more information from the developer and a test case.
Here it is. The button on the top left will bring up a dialog (a dialog
with a giant button). You should see the exception happen when the dialog
comes up. In addition, when you hit the button and dismiss the dialog, the
println after the setVisible(true) is never executed which is probably due
to the exception.
/*
* @(#)SwingApplet.java 1.4 97/10/16
*
* Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
*
* This software is the confidential and proprietary information of Sun
* Microsystems, Inc. ("Confidential Information"). You shall not
* disclose such Confidential Information and shall use it only in
* accordance with the terms of the license agreement you entered into
* with Sun.
*
* SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
* SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
* IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
* SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
* THIS SOFTWARE OR ITS DERIVATIVES.
*
*/
import java.awt.*;
import java.awt.event.*;
import java.net.*;
import java.applet.*;
import com.sun.java.swing.*;
import com.sun.java.swing.text.*;
/**
* A very simple applet.
*/
public class SwingApplet extends JApplet
{
public JDialog jd;
public JTextField one,two,three,four;
public JButton b,b2, b3;
public JComboBox combo;
public JRadioButton radio;
public JCheckBox check;
public JTextPane textPane,textPane2,textPane3;
public void init()
{
JPanel appletPanel = new JPanel();
// Standard applet AWT layout manager method
getContentPane().add(appletPanel);
appletPanel.setSize(getSize());
appletPanel.setLayout(null);
b = new JButton("Test JDialog Exception");
b.setBounds(0,0,200,20);
b2 = new JButton("Hide Components");
b2.setBounds(220,0,200,20);
one = new JTextField("one");
two = new JTextField("one");
three = new JTextField("one");
four = new JTextField("one");
combo = new JComboBox();
radio = new JRadioButton("Radio");
check = new JCheckBox("Check");
// StyleContext sc = new StyleContext();
// DefaultStyledDocument doc = new DefaultStyledDocument(sc);
// DefaultStyledDocument doc = new DefaultStyledDocument();
// PlainDocument doc = new PlainDocument();
public JTextField one,two,three,four;
JButton b3 = new JButton("Insert Text");
b3.setBounds(10,260,120,18);
appletPanel.add(b3);
textPane2 = new JTextPane();
textPane2.setText("");
JScrollPane scrollPane = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
scrollPane.setBounds(10,280,290,100);
scrollPane.getViewport().add(textPane2);
textPane3 = new JTextPane();
textPane3.setText("Blah\nblah\nblah\nblah\ngsdf\nhfdg\nertw\n");
JScrollPane scrollPane3 = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
scrollPane3.setBounds(310,280,290,100);
scrollPane3.getViewport().add(textPane3);
textPane = new JTextPane();
one.setBounds(0,20,300,15);
two.setBounds(0,40,300,15);
three.setBounds(0,60,300,15);
four.setBounds(0,80,300,15);
combo.setBounds(0,100,300,19);
radio.setBounds(0,120,300,19);
check.setBounds(0,140,300,19);
textPane.setBounds(0,160,300,40);
appletPanel.add(b);
appletPanel.add(b2);
appletPanel.add(one);
appletPanel.add(two);
appletPanel.add(three);
appletPanel.add(four);
appletPanel.add(combo);
appletPanel.add(radio);
appletPanel.add(check);
appletPanel.add(textPane);
appletPanel.add(scrollPane);
appletPanel.add(scrollPane3);
System.out.println("Adding Action Performed");
b.addActionListener( new ActionListener()
{
public void actionPerformed(ActionEvent e )
{
System.out.println("Firing Action Performed for b");
startTestDialog();
}
} );
b2.addActionListener( new ActionListener()
{
public void actionPerformed(ActionEvent e )
{
System.out.println("Firing Action Performed for b2");
hideComponents();
}
} );
b3.addActionListener( new ActionListener()
{
public void actionPerformed(ActionEvent e )
{
System.out.println("Firing Action Performed for b2");
changeText();
}
} );
}
public void hideComponents()
{
combo.setVisible(false);
four.setVisible(false);
radio.setVisible(false);
check.setVisible(false);
textPane.setVisible(false);
}
public void changeText()
{
one.setText("Eenie blah blah blah");
two.setText("Meenie blah blah blah");
three.setText("Minie blah blah blah");
four.setText("This JTextField should not be visible");
textPane2.setText("Blah\nblah\nblah\nblah\ngsdf\nhfdg\nertw\n");
}
public void startTestDialog()
{
jd = new JDialog(new Frame(),"Test Dialog",true );
jd.setModal(true);
JButton ok = new JButton("OK");
jd.getContentPane().add(ok);
ok.addActionListener( new ActionListener()
{
public void actionPerformed( ActionEvent e )
{
synchronized(SwingApplet.this)
{
SwingApplet.this.notifyAll();
}
SwingApplet.this.jd.setVisible(false);
synchronized(SwingApplet.this)
{
SwingApplet.this.notifyAll();
}
}
} );
jd.setSize(400,300);
jd.setVisible(true);
System.out.println("I reached the line after setVisible !!");
}
}
Here is the exception:
appletviewer SwingApplet.html
Adding Action Performed
Firing Action Performed for b
Exception occurred during event dispatching:
sun.applet.AppletSecurityException: checkawteventqueueaccess
at sun.applet.AppletSecurity.checkAwtEventQueueAccess(AppletSecurity.java:716)
at java.awt.Toolkit.getSystemEventQueue(Toolkit.java:655)
at com.sun.java.swing.JDialog.blockingShow(JDialog.java:262)
at com.sun.java.swing.JDialog.show(JDialog.java:205)
at java.awt.Component.show(Component.java:498)
at java.awt.Component.setVisible(Component.java:460)
at com.sun.java.swing.JDialog.setVisible(JDialog.java:294)
at SwingApplet.startTestDialog(SwingApplet.java:178)
at SwingApplet$1.actionPerformed(SwingApplet.java:115)
at com.sun.java.swing.AbstractButton.fireActionPerformed(AbstractButton.java:765)
at com.sun.java.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:800)
at com.sun.java.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:314)
at com.sun.java.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:212)
at com.sun.java.swing.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:137)
at java.awt.Component.processMouseEvent(Component.java:2284)
at java.awt.Component.processEvent(Component.java:2129)
at java.awt.Container.processEvent(Container.java:890)
at java.awt.Component.dispatchEventImpl(Component.java:1764)
at java.awt.Container.dispatchEventImpl(Container.java:935)
at java.awt.Component.dispatchEvent(Component.java:1704)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:1539)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:1448)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:1383)
at java.awt.Container.dispatchEventImpl(Container.java:922)
at java.awt.Component.dispatchEvent(Component.java:1704)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:63)
Here is additional information from Mehdi Ghazizadeh:
Cathy,
The problem is in the blockingShow method in JDialgo.java
(or it appears that way)... I don't know what changes they
made in 0.7 release of JFC... but simply fixing setVisible
code will not fix this problem. Try using the show/dispose method
instead of setVisible(true)/setVisible(false) in the test
case and you get the same applet security exception.
Please forward to the appropriate engineer in the JFC team.
Regards,
Mehdi.
-----------------------------------------------------------
ok,
this is bad! bare with me! i'm new to swing.
the JDialgo.java code you're gonna see is taken
from jdk1.2 (yes jdk1.2).. which is far from being released...
I hope it's the same code that JFC team has now... anyway...
this has nothing to do with setVisible.
whether you use setVisible or show they
both eventually call the show method in JDialog.java
which has this code:
class JDialog extends .....
protected boolean realModal;
......
public void setModal(boolean newValue) {
realModal = newValue;
}
.....
public void show() {
super.show(); // this is java.awt.Dialog.show() (which you can
get!)
if(realModal)
blockingShow();
}
now we get into blockingShow which has this code:
protected synchronized void blockingShow() {
try {
// can't use instanceof EventDispatchThread because the class
isn't
public
if
(Thread.currentThread().getClass().getName().endsWith("EventDispa
tchThread")) {
EventQueue theQueue = getToolkit().getSystemEventQueue();
while (isVisible()) {
......
calling getToolkit.getSystemEventQueue() calls Toolkit.java(line 655)
--- getSystemEventQueue() is this:
public final EventQueue getSystemEventQueue() {
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkAwtEventQueueAccess();
}
return getSystemEventQueueImpl();
}
line 655 points to security.checkAwtEventQueueAccess() which
just throws a security exception... in other words the logic
flow dictates that if your run time system has a securitymanger
set... we throw an exception... checkAwtEventQueueAccess is
not a property of the the generic security manager which
is why if this was an application instead of an applet it would
run fine!
i need to talk to javasoft about this... hope at least this
clears up why this is happening...
Regards,
Mehdi.
as duplicate of 4093188. It was incorrectly closed as a duplicate
and am resubmitting as suggested by engineering.
ere is more information from the developer and a test case.
Here it is. The button on the top left will bring up a dialog (a dialog
with a giant button). You should see the exception happen when the dialog
comes up. In addition, when you hit the button and dismiss the dialog, the
println after the setVisible(true) is never executed which is probably due
to the exception.
/*
* @(#)SwingApplet.java 1.4 97/10/16
*
* Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
*
* This software is the confidential and proprietary information of Sun
* Microsystems, Inc. ("Confidential Information"). You shall not
* disclose such Confidential Information and shall use it only in
* accordance with the terms of the license agreement you entered into
* with Sun.
*
* SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
* SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
* IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
* SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
* THIS SOFTWARE OR ITS DERIVATIVES.
*
*/
import java.awt.*;
import java.awt.event.*;
import java.net.*;
import java.applet.*;
import com.sun.java.swing.*;
import com.sun.java.swing.text.*;
/**
* A very simple applet.
*/
public class SwingApplet extends JApplet
{
public JDialog jd;
public JTextField one,two,three,four;
public JButton b,b2, b3;
public JComboBox combo;
public JRadioButton radio;
public JCheckBox check;
public JTextPane textPane,textPane2,textPane3;
public void init()
{
JPanel appletPanel = new JPanel();
// Standard applet AWT layout manager method
getContentPane().add(appletPanel);
appletPanel.setSize(getSize());
appletPanel.setLayout(null);
b = new JButton("Test JDialog Exception");
b.setBounds(0,0,200,20);
b2 = new JButton("Hide Components");
b2.setBounds(220,0,200,20);
one = new JTextField("one");
two = new JTextField("one");
three = new JTextField("one");
four = new JTextField("one");
combo = new JComboBox();
radio = new JRadioButton("Radio");
check = new JCheckBox("Check");
// StyleContext sc = new StyleContext();
// DefaultStyledDocument doc = new DefaultStyledDocument(sc);
// DefaultStyledDocument doc = new DefaultStyledDocument();
// PlainDocument doc = new PlainDocument();
public JTextField one,two,three,four;
JButton b3 = new JButton("Insert Text");
b3.setBounds(10,260,120,18);
appletPanel.add(b3);
textPane2 = new JTextPane();
textPane2.setText("");
JScrollPane scrollPane = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
scrollPane.setBounds(10,280,290,100);
scrollPane.getViewport().add(textPane2);
textPane3 = new JTextPane();
textPane3.setText("Blah\nblah\nblah\nblah\ngsdf\nhfdg\nertw\n");
JScrollPane scrollPane3 = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
scrollPane3.setBounds(310,280,290,100);
scrollPane3.getViewport().add(textPane3);
textPane = new JTextPane();
one.setBounds(0,20,300,15);
two.setBounds(0,40,300,15);
three.setBounds(0,60,300,15);
four.setBounds(0,80,300,15);
combo.setBounds(0,100,300,19);
radio.setBounds(0,120,300,19);
check.setBounds(0,140,300,19);
textPane.setBounds(0,160,300,40);
appletPanel.add(b);
appletPanel.add(b2);
appletPanel.add(one);
appletPanel.add(two);
appletPanel.add(three);
appletPanel.add(four);
appletPanel.add(combo);
appletPanel.add(radio);
appletPanel.add(check);
appletPanel.add(textPane);
appletPanel.add(scrollPane);
appletPanel.add(scrollPane3);
System.out.println("Adding Action Performed");
b.addActionListener( new ActionListener()
{
public void actionPerformed(ActionEvent e )
{
System.out.println("Firing Action Performed for b");
startTestDialog();
}
} );
b2.addActionListener( new ActionListener()
{
public void actionPerformed(ActionEvent e )
{
System.out.println("Firing Action Performed for b2");
hideComponents();
}
} );
b3.addActionListener( new ActionListener()
{
public void actionPerformed(ActionEvent e )
{
System.out.println("Firing Action Performed for b2");
changeText();
}
} );
}
public void hideComponents()
{
combo.setVisible(false);
four.setVisible(false);
radio.setVisible(false);
check.setVisible(false);
textPane.setVisible(false);
}
public void changeText()
{
one.setText("Eenie blah blah blah");
two.setText("Meenie blah blah blah");
three.setText("Minie blah blah blah");
four.setText("This JTextField should not be visible");
textPane2.setText("Blah\nblah\nblah\nblah\ngsdf\nhfdg\nertw\n");
}
public void startTestDialog()
{
jd = new JDialog(new Frame(),"Test Dialog",true );
jd.setModal(true);
JButton ok = new JButton("OK");
jd.getContentPane().add(ok);
ok.addActionListener( new ActionListener()
{
public void actionPerformed( ActionEvent e )
{
synchronized(SwingApplet.this)
{
SwingApplet.this.notifyAll();
}
SwingApplet.this.jd.setVisible(false);
synchronized(SwingApplet.this)
{
SwingApplet.this.notifyAll();
}
}
} );
jd.setSize(400,300);
jd.setVisible(true);
System.out.println("I reached the line after setVisible !!");
}
}
Here is the exception:
appletviewer SwingApplet.html
Adding Action Performed
Firing Action Performed for b
Exception occurred during event dispatching:
sun.applet.AppletSecurityException: checkawteventqueueaccess
at sun.applet.AppletSecurity.checkAwtEventQueueAccess(AppletSecurity.java:716)
at java.awt.Toolkit.getSystemEventQueue(Toolkit.java:655)
at com.sun.java.swing.JDialog.blockingShow(JDialog.java:262)
at com.sun.java.swing.JDialog.show(JDialog.java:205)
at java.awt.Component.show(Component.java:498)
at java.awt.Component.setVisible(Component.java:460)
at com.sun.java.swing.JDialog.setVisible(JDialog.java:294)
at SwingApplet.startTestDialog(SwingApplet.java:178)
at SwingApplet$1.actionPerformed(SwingApplet.java:115)
at com.sun.java.swing.AbstractButton.fireActionPerformed(AbstractButton.java:765)
at com.sun.java.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:800)
at com.sun.java.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:314)
at com.sun.java.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:212)
at com.sun.java.swing.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:137)
at java.awt.Component.processMouseEvent(Component.java:2284)
at java.awt.Component.processEvent(Component.java:2129)
at java.awt.Container.processEvent(Container.java:890)
at java.awt.Component.dispatchEventImpl(Component.java:1764)
at java.awt.Container.dispatchEventImpl(Container.java:935)
at java.awt.Component.dispatchEvent(Component.java:1704)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:1539)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:1448)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:1383)
at java.awt.Container.dispatchEventImpl(Container.java:922)
at java.awt.Component.dispatchEvent(Component.java:1704)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:63)
Here is additional information from Mehdi Ghazizadeh:
Cathy,
The problem is in the blockingShow method in JDialgo.java
(or it appears that way)... I don't know what changes they
made in 0.7 release of JFC... but simply fixing setVisible
code will not fix this problem. Try using the show/dispose method
instead of setVisible(true)/setVisible(false) in the test
case and you get the same applet security exception.
Please forward to the appropriate engineer in the JFC team.
Regards,
Mehdi.
-----------------------------------------------------------
ok,
this is bad! bare with me! i'm new to swing.
the JDialgo.java code you're gonna see is taken
from jdk1.2 (yes jdk1.2).. which is far from being released...
I hope it's the same code that JFC team has now... anyway...
this has nothing to do with setVisible.
whether you use setVisible or show they
both eventually call the show method in JDialog.java
which has this code:
class JDialog extends .....
protected boolean realModal;
......
public void setModal(boolean newValue) {
realModal = newValue;
}
.....
public void show() {
super.show(); // this is java.awt.Dialog.show() (which you can
get!)
if(realModal)
blockingShow();
}
now we get into blockingShow which has this code:
protected synchronized void blockingShow() {
try {
// can't use instanceof EventDispatchThread because the class
isn't
public
if
(Thread.currentThread().getClass().getName().endsWith("EventDispa
tchThread")) {
EventQueue theQueue = getToolkit().getSystemEventQueue();
while (isVisible()) {
......
calling getToolkit.getSystemEventQueue() calls Toolkit.java(line 655)
--- getSystemEventQueue() is this:
public final EventQueue getSystemEventQueue() {
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkAwtEventQueueAccess();
}
return getSystemEventQueueImpl();
}
line 655 points to security.checkAwtEventQueueAccess() which
just throws a security exception... in other words the logic
flow dictates that if your run time system has a securitymanger
set... we throw an exception... checkAwtEventQueueAccess is
not a property of the the generic security manager which
is why if this was an application instead of an applet it would
run fine!
i need to talk to javasoft about this... hope at least this
clears up why this is happening...
Regards,
Mehdi.