This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 235508 - 2 TopComponents in different invokeLater
Summary: 2 TopComponents in different invokeLater
Status: NEW
Alias: None
Product: platform
Classification: Unclassified
Component: Window System (show other bugs)
Version: 7.3.1
Hardware: PC Unix
: P4 normal (vote)
Assignee: Stanislav Aubrecht
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-09-04 14:18 UTC by myst3r10n
Modified: 2013-09-05 09:31 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description myst3r10n 2013-09-04 14:18:29 UTC
I recognized a confusing behavior by using two TopComponents in different invokeLater. Example in Scala:

val f1 = new TopComponent { setName("f1") }
val f2 = new TopComponent { setName("f2") }

SwingUtilities.invokeLater(new Runnable { def run { f1.open }})
SwingUtilities.invokeLater(new Runnable { def run { f2.open }})

Afer running the both TopComponents switching nonstop his focus against: f1 -> f2 -> f1 -> ...

If I use a Thread.sleep(5000) between first invokeLater and the second. Then this strange behavior doesn't happen. I found out that this behavior is a result of the tc.requestActive(); in the TopComponent.java file. More Precisely in the topComponentOpen function.
Comment 1 myst3r10n 2013-09-04 14:25:27 UTC
Sorry, I mean the file DummyWindowManager.java
Comment 2 myst3r10n 2013-09-04 14:44:36 UTC
Well, the tc.requestActive() is not the real problem. I found out that it's the f.toFront(); in the DummyWindowManager.java file. If I wrap the f.toFront in a comment block. Then all works fine. Example:

protected void topComponentRequestActive(TopComponent tc) {
    JFrame f = (JFrame) SwingUtilities.getAncestorOfClass(JFrame.class, tc);
/*
    if (f != null) {
        f.toFront();
    }
*/
    registry().setActive(tc);
    activateComponent(tc);
}
Comment 3 Stanislav Aubrecht 2013-09-05 09:31:39 UTC
Any special reason to use DummyWindowManager?