This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug AWT/16762] New: Cannot dispatch MouseEvents to components that have just been removed.
- From: "gcc-bugzilla at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 27 Jul 2004 00:39:14 -0000
- Subject: [Bug AWT/16762] New: Cannot dispatch MouseEvents to components that have just been removed.
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
>From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040510
Description of problem:
I have the following piece of code:
final JFrame f = new JFrame();
final JButton a = new JButton("button");
a.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
f.remove(a);
}
});
f.getContentPane().add(a);
f.pack();
f.show();
When you click on the button that shows up, it whines about NPEs when
acquiring a target for the mouse events. In Sun's, it does remove the
button (but does not update the frame until you do something to it).
Version-Release number of selected component (if applicable):
How reproducible:
Always
Steps to Reproduce:
Run the sample code.
Actual Results: Exception thrown is:
Exception during event dispatch:
java.lang.NullPointerException
at java.awt.Component.getLocationOnScreen()
(/home/kho/gcj-inst/i686-pc-linux-gnu/libjava/.libs/lib-java-awt.so.0.0.0)
at
javax.swing.SwingUtilities.convertPointFromScreen(java.awt.Point,
java.awt.Component)
(/home/kho/gcj-inst/i686-pc-linux-gnu/libjava/.libs/lib-javax-swing.so.0.0.0)
at javax.swing.SwingUtilities.convertPoint(java.awt.Component, int,
int, java.awt.Component)
(/home/kho/gcj-inst/i686-pc-linux-gnu/libjava/.libs/lib-javax-swing.so.0.0.0)
at
java.awt.LightweightDispatcher.acquireComponentForMouseEvent(java.awt.event.MouseEvent)
(/home/kho/gcj-inst/i686-pc-linux-gnu/libjava/.libs/lib-java-awt.so.0.0.0)
at java.awt.LightweightDispatcher.handleEvent(java.awt.AWTEvent)
(/home/kho/gcj-inst/i686-pc-linux-gnu/libjava/.libs/lib-java-awt.so.0.0.0)
at java.awt.Container.dispatchEventImpl(java.awt.AWTEvent)
(/home/kho/gcj-inst/i686-pc-linux-gnu/libjava/.libs/lib-java-awt.so.0.0.0)
at java.awt.Window.dispatchEventImpl(java.awt.AWTEvent)
(/home/kho/gcj-inst/i686-pc-linux-gnu/libjava/.libs/lib-java-awt.so.0.0.0)
at java.awt.Component.dispatchEvent(java.awt.AWTEvent)
(/home/kho/gcj-inst/i686-pc-linux-gnu/libjava/.libs/lib-java-awt.so.0.0.0)
at java.awt.EventQueue.dispatchEvent(java.awt.AWTEvent)
(/home/kho/gcj-inst/i686-pc-linux-gnu/libjava/.libs/lib-java-awt.so.0.0.0)
at java.awt.EventDispatchThread.run()
(/home/kho/gcj-inst/i686-pc-linux-gnu/libjava/.libs/lib-java-awt.so.0.0.0)
at _Jv_ThreadRun(java.lang.Thread)
(/home/kho/gcj-inst/i686-pc-linux-gnu/libjava/.libs/libgcj.so.6.0.0)
at GC_start_routine
(/home/kho/gcj-inst/i686-pc-linux-gnu/libjava/.libs/libgcj.so.6.0.0)
at __clone (/lib/tls/libc-2.3.3.so)
Expected Results: The button is removed from the frame.
Additional info:
------- Additional Comments From djee at redhat dot com 2004-05-31 10:26 -------
The problem was in Container.remove(). A removed component should be
set to invisible after it is removed, but this was not being done.
The Component.getLocationOnScreen() method was getting tripped up over
this inconsistency.
The fix is now in the java-gui-branch. Please verify with the test
case mentioned in the original bug report.
------- Additional Comments From kho at redhat dot com 2004-05-31 15:14 -------
verified.
--
Summary: Cannot dispatch MouseEvents to components that have just
been removed.
Product: gcc
Version: 3.5.0
Status: UNCONFIRMED
Severity: enhancement
Priority: P1
Component: AWT
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: kho at redhat dot com
CC: gcc-bugs at gcc dot gnu dot org,kho at redhat dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16762