Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
Bug 169373 - Visual Library - Embedded Swing components paint problem
Visual Library - Embedded Swing components paint problem
Status: RESOLVED FIXED
Product: platform
Classification: Unclassified
Component: Graph
6.x
All All
: P2 (vote)
: 6.x
Assigned To: t_h
issues@platform
:
Depends on:
Blocks:
  Show dependency treegraph
 
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
:


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


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo