harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrey Pavlenko (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HARMONY-4613) [classlib][swing] SetOptions/SetMessage of JOptionPane not implemented
Date Wed, 22 Aug 2007 08:54:30 GMT

    [ https://issues.apache.org/jira/browse/HARMONY-4613?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12521736
] 

Andrey Pavlenko commented on HARMONY-4613:
------------------------------------------

This fix caused a regression. To reproduce it use the following code:

import javax.swing.JFrame;
import javax.swing.JOptionPane;

public class SwingTest {

	public static void main(String[] args) {
		JFrame f = new JFrame();
		JOptionPane.showMessageDialog(f, "Push the below button");
		f.dispose();
	}
}

After pressing the "OK" button NPE in the EventDispatchThread occures:

java.lang.NullPointerException
	at javax.swing.plaf.basic.BasicOptionPaneUI$ButtonActionListener.actionPerformed(BasicOptionPaneUI.java:274)
	at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:704)
	at javax.swing.AbstractButton$ActionAndModelListener.actionPerformed(AbstractButton.java:241)
	at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:220)
	at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:152)
	at javax.swing.plaf.basic.BasicButtonListener$ReleaseButtonAction.release(BasicButtonListener.java:68)
	at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:126)
	at java.awt.Component.processMouseEventImpl(Component.java:3973)
	at java.awt.Component.processMouseEvent(Component.java:3954)
	at java.awt.Component.processEvent(Component.java:3637)
	at java.awt.Container.processEvent(Container.java:1293)
	at java.awt.Component.dispatchEvent(Component.java:3547)
	at java.awt.EventQueueCore.dispatchEventImpl(EventQueueCore.java:149)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:144)
	at java.awt.EventDispatchThread.runModalLoop(EventDispatchThread.java:68)
	at java.awt.ModalContext.runModalLoop(ModalContext.java:43)
	at java.awt.Dialog$DialogModalContext.runModalLoop(Dialog.java:41)
	at java.awt.Dialog.showModal(Dialog.java:362)
	at java.awt.Dialog.access$0(Dialog.java:351)
	at java.awt.Dialog$1.run(Dialog.java:254)
	at java.awt.event.InvocationEvent.runAndNotify(InvocationEvent.java:92)
	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:81)
	at java.awt.EventQueueCore.dispatchEventImpl(EventQueueCore.java:138)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:144)
	at java.awt.EventDispatchThread.runModalLoop(EventDispatchThread.java:68)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:48)

It happens because the method javax.swing.JOptionPane.setValue(Object), you've modified, 
is used by the event listener associated with the current instance of BasicOptionPaneUI (method
BasicOptionPaneUI$ButtonActionListener.actionPerformed()). The method updateUI(), which you've
added to the end of setValue(), uninstalls the current UI and replaces it with a new instance
of BasicOptionPaneUI. Thus, we have a situation when during event processing the listener
uninstalls UI and after that tries to modify it. This is the cause of NPE.


> [classlib][swing] SetOptions/SetMessage of JOptionPane not implemented
> ----------------------------------------------------------------------
>
>                 Key: HARMONY-4613
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4613
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>         Environment: win32
>            Reporter: Chunrong Lai
>            Assignee: Alexey Petrenko
>         Attachments: HARMONY-4613.patch, Harmony.jpg, RI.JPG
>
>
> Here's the simple test demonstrating the problem: 
> import javax.swing.*;
> public class OptionPaneTest {
>   public static void main(String[] args) {
>         JFrame frame = new JFrame("OPTest");
>         JButton yesButton = new JButton("Yes");
>         JButton noButton = new JButton("No");
>         JButton[]   buttons = {yesButton, noButton};
>         JDialog dialog = new JDialog(frame, true);
>         dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
>         JOptionPane optionPane = new JOptionPane();;
>         optionPane.setMessageType(JOptionPane.PLAIN_MESSAGE);
>         optionPane.setOptions(buttons);
>         optionPane.setMessage("Can we show the dislog?");
>         dialog.setTitle("JOptionPane Test");
>         dialog.getContentPane().add(optionPane);
>         dialog.pack();
>         dialog.setLocationRelativeTo(dialog.getParent());
>         dialog.show();
>   }
> }
>  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message