Skip to main content

REPOST: JXTaskPaneContainer Background Colour

6 replies [Last post]
fommil
Offline
Joined: 2006-11-26
Points: 0

(Bizarre, my last post is showing up in the list but is not clickable. Let's put it down to the java.net migration... although there was an identically named post some years ago and maybe non-unique URLs are causing a problem)

On OS X, the JXTaskPaneContainer (and JXTaskPane) use a very light background colour that seems to be outside the control of the setBackground(Color) method. It looks nice, but there are two problems:

1. sometimes I would like to be able to set these to be the same colour as their parent
2. if I place a JPanel inside a JXTaskPane, it inherits the background colour of the JXTaskPaneContainer's parent - which might not be appropriate at all!

As an OS X Lion workaround only, I can set the background colour of my JPanels, but I would prefer for background colours to be automatically inherited and for me to be able to get the colour using standard means.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
fommil
Offline
Joined: 2006-11-26
Points: 0

more on point 2 - the background colour inherited by members of the JXTaskPane seems to depend on their opacity value. I have not yet been able to isolate exactly what causes this, but I am getting very ugly entries which have a different background colour to the JXTaskPane, even though their backgrounds are not being set.

kschaefe
Offline
Joined: 2006-06-08
Points: 0

Can you attach an image? I am having trouble visualizing what you are saying....it could be my lack of coffee.

Karl

fommil
Offline
Joined: 2006-11-26
Points: 0

I was hoping to send you a standalone test case, but I can't easily reproduce the problem.

I haven't explicitly set the background colour or opacity of any of these components.

The hierarchy of this screenshot is:

JFrame -> JTabbedPane -> JPanel -> JScrollPane -> JXTaskPaneContainer -> JXTaskPane -> MyComponent
-> JToolbar -> (buttons, etc)

fommil
Offline
Joined: 2006-11-26
Points: 0

even better, I have that standalone test case! I'm not 100% which bit is causing this, so you can probably experiment by removing components. (my screenshot attached)

Note: this works with or without the BLACK background line - I set it to be black so that it is more obvious. On OS X Lion, the difference in colour for this particular example is very subtle, but it is definitely there.

import java.awt.Color;
import javax.swing.JFrame;
import org.jdesktop.swingx.JXTaskPane;
import org.jdesktop.swingx.JXTaskPaneContainer;

public class TestJXTaskPane extends JXTaskPane {

    public TestJXTaskPane() {
        initComponents();
    }

    public static void main(String args[]) {
        JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setBackground(Color.BLACK);
       
        JXTaskPaneContainer container = new JXTaskPaneContainer();
        container.add(new TestJXTaskPane());
       
        frame.add(container);
       
        frame.pack();
        frame.setVisible(true);
    }

    /**
     * WARNING: Do NOT modify this code.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jToolBar = new javax.swing.JToolBar();
        jXReloadButton = new org.jdesktop.swingx.JXButton();
        filler1 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 25), new java.awt.Dimension(0, 1000));
        jXRemoveButton = new org.jdesktop.swingx.JXButton();
        jPanel2 = new javax.swing.JPanel();

        jPanel1.setLayout(new java.awt.BorderLayout());

        jToolBar.setFloatable(false);
        jToolBar.setOrientation(1);

        jXReloadButton.setText("Reload");
        jXReloadButton.setFocusable(false);
        jXReloadButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jXReloadButton.setMaximumSize(new java.awt.Dimension(54, 18));
        jXReloadButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar.add(jXReloadButton);
        jToolBar.add(filler1);

        jXRemoveButton.setText("Remove");
        jXRemoveButton.setFocusable(false);
        jXRemoveButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jXRemoveButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar.add(jXRemoveButton);

        jPanel1.add(jToolBar, java.awt.BorderLayout.EAST);

        jPanel2.setLayout(new java.awt.BorderLayout());
        jPanel1.add(jPanel2, java.awt.BorderLayout.CENTER);

        add(jPanel1, java.awt.BorderLayout.CENTER);
    }// </editor-fold>

    // Variables declaration - do not modify
    private javax.swing.Box.Filler filler1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JToolBar jToolBar;
    private org.jdesktop.swingx.JXButton jXReloadButton;
    private org.jdesktop.swingx.JXButton jXRemoveButton;
    // End of variables declaration
}
kschaefe
Offline
Joined: 2006-06-08
Points: 0

I see you filed this as a bug. Thanks for the standalone test case.

Karl

fommil
Offline
Joined: 2006-11-26
Points: 0

I'm still getting this with SwingX 1.6.4 from the staging area.