Container panels transparent in JInternalFrame with Windows XP Style

Hi All

I have a problem with a GUI where panels extending java.awt.Container (added to JInternalFrame) are transparent when using Windows XP Style (Windows XP Pro). The components added to the Container (for example JButton, JComboBox etc.) paint correctly but the surrounding space of the Container to which they belong is translucent such that the desktop below can be seen.

When I switch to Windows Classic Style this does not happen. I'm using JDK6.0.

Has anyone encountered this problem?

Help appreciated

Lance

[553 byte] By [LanceJa] at [2007-11-26 17:28:57]
# 1

Just an update; this is the config I'm using to bootstrap the app (in main):

UIManager.put("swing.boldMetal", Boolean.FALSE);

UIManager.put("ToolTip.background", Color.YELLOW);

JDialog.setDefaultLookAndFeelDecorated(true);

JFrame.setDefaultLookAndFeelDecorated(true);

Toolkit.getDefaultToolkit().setDynamicLayout(true);

System.setProperty("sun.awt.noerasebackground","true");

UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

The GUI is assembled from basic panels which extend Container, typical example below:

public class BottomContainer extends Container implements ActionListener {

private ActionListener handler;

private ModeButton closeCancelButton;

private JProgressBar progressBar;

private ResourceBundle bundle;

public BasicBottomContainer(ResourceBundle bundle) {

super();

this.bundle = bundle;

createGui();

}

public void actionPerformed(ActionEvent e) {

Object source = e.getSource();

ActionEvent xEvent = null; // translated event

if (source == closeCancelButton) {

ButtonModes mode = ((ModeButton) source).getMode();

if (mode == ButtonModes.CANCEL) {

xEvent = new ProxyActionEvent(ActionProxies.CANCEL_BUTTON);

} else if (mode == ButtonModes.CLOSE) {

xEvent = new ProxyActionEvent(ActionProxies.CLOSE_BUTTON);

} else {

throw new IllegalArgumentException("Mode not defined");

}

} else {

throw new IllegalArgumentException("Source not defined");

}

handler.actionPerformed(xEvent);

}

private void createGui() {

setLayout(new BoxLayout(this, BoxLayout.X_AXIS));

progressBar = new JProgressBar();

progressBar.setMinimum(0);

progressBar.setMaximum(100);

progressBar.setVisible(false);

JPanel progressPanel = new JPanel();

progressPanel.setLayout(new BorderLayout());

progressPanel.add(progressBar, BorderLayout.CENTER);

GuiUtils.setFixedSize(progressPanel, 200, 13);

progressPanel.setVisible(false);

ButtonModes mode = ButtonModes.CLOSE;

closeCancelButton = new ModeButton(bundle.getString("closeButton"), mode);

localeChangeList.add(closeCancelButton, "closeButton");

closeCancelButton.setMinimumSize(new Dimension(80, 25));

closeCancelButton.addActionListener(this);

add(GuiUtils.rigidArea(15, 55)); // spacing with left-hand border & height

add(progressPanel);

add(Box.createHorizontalGlue()); // push apart

add(closeCancelButton);

add(GuiUtils.rigidArea(15, 0)); // spacing with right-hand border

setVisible(false);

}

public void updateRefreshProgress(int refreshProgress) {

progressBar.setValue(refreshProgress);

}

public void setCloseCancelButtonMode(ButtonModes mode) {

closeCancelButton.setMode(mode);

}

public void setHandler(ActionListener handler) {

this.handler = handler;

}

}

The Container above is then attached in the main GUI something like this:

public abstract class TestView extends AbstractView {

protected TopContainer topContainer;

protected MiddleContainer middleContainer;

protected BottomContainer bottomContainer;

public AbstractView() {

createGui();

}

private void createGui() {

topContainer = new TopContainer(model.getBundle());

middleContainer = new MiddleContainer();

bottomContainer = new BottomContainer(model.getBundle());

infoPanel.setVisible(false);

container.setLayout(new BoxLayout(container, BoxLayout.Y_AXIS));

container.add((Container) topContainer);

container.add((Container) middleContainer);

container.add(infoPanel.getContainer());

container.add((Container) bottomContainer);

}

protected void dispose() {

super.dispose();

}

public final void showGui(boolean visible) {

super.showGui(visible);

topContainer.setVisible(true);

middleContainer.setVisible(true);

bottomContainer.setVisible(true);

}

}

It appears that all the components (e.g. BottomContainer, TopContainer etc)

which extend Container are transparent but I'm not able to replicate it with a simpler class (the panels are always opaque in simpler setup).

Has anyone seen this before (as I mentioned above, this only happens when I set my config for Windows XP Pro to 'Windows XP Style' in the Control Panel).

Help much appreciated

Lance

LanceJa at 2007-7-8 23:56:53 > top of Java-index,Desktop,Core GUI APIs...
# 2
Yet another update, I managed to solve the issue.In JInternalFrame, I was using setContentPane(Container) to attach the main Container for the GUI. Using JInternalFrame.getContentPane().add(Container) solved the problem.
LanceJa at 2007-7-8 23:56:53 > top of Java-index,Desktop,Core GUI APIs...