HeavyWeight components with Java 6 update 14

Hello
I have heavyweight component (Canvas) inside a JPanel and the JPanel to a dockable. With Java 6 until update 13 all worked fine, but with Java update 14 the heavyweight component is added to the JPanel but never shown. Any thoughts?
Thanks!

Ohm no idea yet…, if you just put the Canvas on some JPanels and those on a JFrame, without using DF, is the Canvas then invisible as well?

In general, mixing AWT components and Swing components ain’t too good. Is it a hard job to change the Canvas to a JComponent derivate? Have you tried to disable double buffering on the Canvas’ parent? Does the canvas show when the layout changes while the frame is visible (e. g. resize)? On what platform(s) are you testing?

BR, Ebenius

if you just put the Canvas on some JPanels and those on a JFrame, without using DF, is the Canvas then invisible as well?

No the canvas is shown fine, if I put it in JPanel and the JPanel in JFrame.

In general, mixing AWT components and Swing components ain’t too good. Is it a hard job to change the Canvas to a JComponent derivate? Have you tried to disable double buffering on the Canvas’ parent? Does the canvas show when the layout changes while the frame is visible (e. g. resize)? On what platform(s) are you testing?

I want to use a SWT Browser component in a Swing application, and the only way seems to be to host it in a SWT shell which is made in this way according to SWT instructions:
Shell shell = SWT_AWT.new_Shell(display, canvas);
So I need a AWT Canvas.
I tried disabling double buffering on the canvas’ parent and resizing without any result.
I test on Windows XP.

Below is the test code I use to see the canvas problem. With blue I paint the JPanel which hosts the Canvas which is painted in black. With comments is the line with which the JFrame hosts directly the JPanel with the Canvas (in that case all seem correctly) instead of hosting the gridArea.

JFrame frame = new JFrame();
CControl control = new CControl(frame);
CGridArea gridArea = control.createGridArea("grid");
JPanel panel = new JPanel();
panel.setBackground(Color.BLUE);
panel.setDoubleBuffered(false);
Canvas canvas = new Canvas();
canvas.setBackground(Color.black);
panel.setLayout(new GridLayout(1, 1));
panel.add(canvas);
DefaultSingleCDockable dockable = new DefaultSingleCDockable("panel", panel);
control.add(dockable);
dockable.setLocation(CLocation.normalized(gridArea));
dockable.setVisible(true);
frame.setContentPane(gridArea.getComponent());
//frame.setContentPane(panel);
frame.pack();
frame.setSize(400, 300);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
frame.setVisible(true);

I’ll try this out once I find a computer with win xp, which is not before tomorrow.

ok, by the way I just tried it also on Vista (if you prefer that operating system) and there is the same odd behavior.

I’m having the same problem. Canvas is drawn behind the JPanel.
It is a feature of update 14, mixing lightweight and heavyweight components.
You can bypass the problem by setting the following option:
-Dsun.awt.disableMixing=true

May be it has sonething to do with the Z order.
But, I prefer a fix in DockingFrames thou :slight_smile:

Indeed that seems to be the solution! Read also the following reports:

Bug ID: 6788954 Need to introduce sun.awt.disableMixing system property

Bug ID: 6776743 Lightweight components must be counted as opaque rectangles for the purposes of hw/lw mixing

Thanks for these infos, DF uses glass-panes extensively for painting. According to the two bug reports that is the cause of all problems. So I’ll make sure all glass-panes call this “AWTUtilities.setComponentNonOpaqueForMixing” method, and you can use “-Dsun.awt.disableMixing=true” in the mean time.