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 169373 - Visual Library - Embedded Swing components paint problem
Summary: Visual Library - Embedded Swing components paint problem
Status: RESOLVED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Graph (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker (vote)
Assignee: t_h
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-07-28 19:24 UTC by mwalters
Modified: 2009-09-18 22:32 UTC (History)
1 user (show)

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 mwalters 2009-07-28 19:24:07 UTC
You can see this problem in one of the Visual Library demos:

test.component.ComponentTest

Drag a component on top of another component and you will see the that the swing components "bleed through" the widgets.

Note: widget.setOpaque(true) does not solve this problem.  Without a fix for this, the visual library is useless for
anyone serious about embedding swing components into a scene.

It looks like the swing components "bleed through" because they (the swing components inside ComponentWidget) get added
directly as children to the scene's view:

Code:
scene.getView ().add (component);


Here's the full method from ComponentWidget:

Code:

    private void addComponent () {
        Scene scene = getScene ();
        if (! componentAdded) {
            scene.getView ().add (component);
            scene.getView ().revalidate ();
            component.addComponentListener (componentListener);
            componentAdded = true;
        }
        component.removeComponentListener (componentListener);
        component.setBounds (scene.convertSceneToView (convertLocalToScene (getClientArea ())));
        component.addComponentListener (componentListener);
        component.repaint ();
    }


This means they (the swing components) have a different z-order than the widgets.

This also means that if you want to "bring to front" a widget with a swing component, this method must be overridden and
the component must be added as a child with index 0 (on the parent).

It would be great if this could be fixed so that the swing components get painted within the widget (instead of by the
scene view's paintChildren method). There is a paintWidget() method on the ComponentWidget, but it does not appear to be
painting the swing components the way that they were intended to painted.

When this is fixed, please check it with a JTable or JList with a custom renderer. My fix still allows the renderers to
"bleed through" the other swing components (when their parent widget is dragged over another swing component).

Also, can you remove the "final" from the bringToFront/Back() methods.
Comment 1 Antonin Nebuzelsky 2009-07-29 12:21:13 UTC
Will be evaluated for 6.8.
Comment 2 t_h 2009-09-17 11:53:20 UTC
da7547f37f44
Comment 3 Quality Engineering 2009-09-18 22:32:16 UTC
Integrated into 'main-golden', will be available in build *200909181401* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/da7547f37f44
User: Tomas Holy <t_h@netbeans.org>
Log: #169373: Embedded Swing components paint problem