Details
-
Type:
Bug
-
Status: Closed
-
Priority:
P2
-
Resolution: Duplicate
-
Affects Version/s: 1.1.3, 1.1.4, 1.1.5
-
Fix Version/s: None
-
Component/s: client-libs
-
Subcomponent:
-
CPU:x86, sparc
-
OS:solaris_2.5.1, solaris_2.6, windows_nt
Description
Modal dialogs which were launched by JButton cause NULLPointerException error when it is closed by setVisible(false)
As a result of setVisible(false), dialogs disappear but cause an Exception error as follows:
java.lang.NullPointerException at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:1416)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:1329)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:1264)
at java.awt.Container.dispatchEventImpl(Container.java:824)
at java.awt.Window.dispatchEventImpl(Window.java:401)
at java.awt.Component.dispatchEvent(Component.java:1393)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:63)
Here is test-code that causes exception.
// test-code
import java.awt.*;
import java.awt.event.*;
import com.sun.java.swing.*;
public class DialogWindow extends JFrame implements ActionListener{
private AboutFrame dialog;
public DialogWindow() {
super("test");
//**** if Button is used then no exception under solaris ****//
JButton button = new JButton("Click to bring up dialog");
button.addActionListener(this);
add(button);
addWindowListener(wl);
}
WindowListener wl = new WindowAdapter(){
public void windowClosing(WindowEvent event){
System.exit(0);
}
};
public void actionPerformed(ActionEvent event) {
if(dialog == null) dialog = new AboutFrame(this);
dialog.setVisible(true);
}
public static void main(String args[]) {
DialogWindow window = new DialogWindow();
window.pack();
window.setVisible(true);
}
}
class AboutFrame extends Dialog implements ActionListener
{
JPanel upperPanel;
JPanel lowerPanel;
public AboutFrame(JFrame frame){
super(frame, "Cool AWT Test Team!!!", true);
setSize(300,200);
upperPanel = new JPanel(true);
lowerPanel = new JPanel(true);
lowerPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
JButton ok = new JButton("OK");
ok.setActionCommand("OK");
ok.addActionListener(this);
lowerPanel.add(ok);
add("Center", upperPanel);
add("South", lowerPanel);
}
public void actionPerformed(ActionEvent e){
if((e.getActionCommand()).equals("OK")){
setVisible(false); // cause exception.
}
}
}
// The end of the test-code.
bae-chul.kim@Eng 1997-06-25
As a result of setVisible(false), dialogs disappear but cause an Exception error as follows:
java.lang.NullPointerException at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:1416)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:1329)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:1264)
at java.awt.Container.dispatchEventImpl(Container.java:824)
at java.awt.Window.dispatchEventImpl(Window.java:401)
at java.awt.Component.dispatchEvent(Component.java:1393)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:63)
Here is test-code that causes exception.
// test-code
import java.awt.*;
import java.awt.event.*;
import com.sun.java.swing.*;
public class DialogWindow extends JFrame implements ActionListener{
private AboutFrame dialog;
public DialogWindow() {
super("test");
//**** if Button is used then no exception under solaris ****//
JButton button = new JButton("Click to bring up dialog");
button.addActionListener(this);
add(button);
addWindowListener(wl);
}
WindowListener wl = new WindowAdapter(){
public void windowClosing(WindowEvent event){
System.exit(0);
}
};
public void actionPerformed(ActionEvent event) {
if(dialog == null) dialog = new AboutFrame(this);
dialog.setVisible(true);
}
public static void main(String args[]) {
DialogWindow window = new DialogWindow();
window.pack();
window.setVisible(true);
}
}
class AboutFrame extends Dialog implements ActionListener
{
JPanel upperPanel;
JPanel lowerPanel;
public AboutFrame(JFrame frame){
super(frame, "Cool AWT Test Team!!!", true);
setSize(300,200);
upperPanel = new JPanel(true);
lowerPanel = new JPanel(true);
lowerPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
JButton ok = new JButton("OK");
ok.setActionCommand("OK");
ok.addActionListener(this);
lowerPanel.add(ok);
add("Center", upperPanel);
add("South", lowerPanel);
}
public void actionPerformed(ActionEvent e){
if((e.getActionCommand()).equals("OK")){
setVisible(false); // cause exception.
}
}
}
// The end of the test-code.
bae-chul.kim@Eng 1997-06-25
Attachments
Issue Links
- duplicates
-
JDK-4088011 Dismissing dialogs throws exceptions
-
- Closed
-
- relates to
-
JDK-4038897 lightweight components mouse tracking not delivering events, causing exception
-
- Closed
-
-
JDK-4058359 LightweightDispatcher has race problem with Modal dialogs.
-
- Closed
-