swingx
  1. swingx
  2. SWINGX-1435

JXTitledPane, JXCollapsiblePane and JXTaskPane opacity issues

    Details

      Description

      These 3 components have a content pane that holds the content to be shown. The opacity of the content pane should be treated independently and this is working as intended.

      • JXTitledPane
        This component is non opaque by default as well as its content pane. This seems not to make much sense in comparison with most of the components.
      • JXCollapsiblePane
        Works fine
      • JXTaskPane
        This component is opaque by default. In this component as it has rounded corners (although it would depend on the LaF) in the top would make sense it was translucent.
        The wrapper is opaque and we need to use a workaround to make it translucent. The same happened to JXTitledPane and was fixed.

      I'm writting this issues altogether to make a comparison, would break it up in different issues if needed.

      Example code:

      import java.awt.Color;
      import java.awt.Component;
      import java.awt.Container;

      import javax.swing.Box;
      import javax.swing.JComponent;
      import javax.swing.JFrame;
      import javax.swing.JSeparator;
      import javax.swing.SwingConstants;
      import javax.swing.SwingUtilities;
      import javax.swing.border.EmptyBorder;

      import org.jdesktop.swingx.JXButton;
      import org.jdesktop.swingx.JXCollapsiblePane;
      import org.jdesktop.swingx.JXFrame;
      import org.jdesktop.swingx.JXFrame.StartPosition;
      import org.jdesktop.swingx.JXLabel;
      import org.jdesktop.swingx.JXPanel;
      import org.jdesktop.swingx.JXTaskPane;
      import org.jdesktop.swingx.JXTextField;
      import org.jdesktop.swingx.JXTitledPanel;
      import org.jdesktop.swingx.VerticalLayout;
      import org.jdesktop.swingx.painter.CompoundPainter;
      import org.jdesktop.swingx.painter.GlossPainter;
      import org.jdesktop.swingx.painter.MattePainter;

      public class PanelsOpacityTest {

      protected static Color DARK_BLUE = new Color(99, 130, 191);
      protected static Color LIGHT_BLUE = new Color(184, 207, 229);

      public static void main(String... args ) {
      JFrame.setDefaultLookAndFeelDecorated(true);

      SwingUtilities.invokeLater(new Runnable() {
      @Override
      public void run() {
      JXFrame frame = new JXFrame("Opacity test for JXCollapsiblePane and JXTitlePanel");
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.setStartPosition(StartPosition.CenterInScreen);

      JXPanel contentPane = new JXPanel(new VerticalLayout());
      contentPane.setBackgroundPainter(new CompoundPainter<JXPanel>(new MattePainter(DARK_BLUE), new GlossPainter(LIGHT_BLUE)));
      frame.setContentPane(contentPane);

      JXTitledPanel titledPanel = new JXTitledPanel("JXTitledPanel");
      System.out.println("JXTitledPanel default opacity = " + titledPanel.isOpaque());
      addSomeTranslucentContentTo(titledPanel.getContentContainer());
      // titledPanel.setOpaque(false); // It's translucent by default. Is this correct?
      // ((JComponent) titledPanel.getComponent(0)).setOpaque(false); // For making the wrapper translucent. Fixed. Not needed any more as of 1.6.3
      // ((JComponent) titledPanel.getContentContainer()).setOpaque(true); // For making the content pane translucent. Working as intended

      JXCollapsiblePane collapsiblePane = new JXCollapsiblePane();
      System.out.println("JXCollapsiblePane default opacity = " + collapsiblePane.isOpaque());
      addSomeTranslucentContentTo(collapsiblePane.getContentPane());
      collapsiblePane.setOpaque(false);
      ((JComponent) collapsiblePane.getContentPane()).setOpaque(false);

      JXTaskPane taskPane = new JXTaskPane("JXTaskPane");
      System.out.println("JXTaskPane default opacity = " + taskPane.isOpaque());
      addSomeTranslucentContentTo(taskPane.getContentPane());
      taskPane.setOpaque(false); // It's opaque by default. While this makes sense notice the top corners: this should be transparent (check setting to true)
      ((JComponent) taskPane.getComponent(0)).setOpaque(false); // For making the wrapper translucent. This shouldn't be needed
      ((JComponent) taskPane.getContentPane()).setOpaque(false); // For making the content pane translucent. Correct

      contentPane.add(createOpacitityTestPanelFor(titledPanel));
      contentPane.add(new JSeparator(SwingConstants.HORIZONTAL));
      contentPane.add(createOpacitityTestPanelFor(createControlPanelFor(collapsiblePane), collapsiblePane));
      contentPane.add(new JSeparator(SwingConstants.HORIZONTAL));
      contentPane.add(createOpacitityTestPanelFor(taskPane));

      frame.pack();
      frame.setVisible(true);
      }});
      }

      protected static JXPanel createOpacitityTestPanelFor(Component... components) {
      JXPanel testPanel = new JXPanel(new VerticalLayout());
      testPanel.setOpaque(false);
      testPanel.setBorder(new EmptyBorder(10, 10, 10, 10));

      for (Component component : components)

      { testPanel.add(component); }

      return testPanel;
      }

      protected static JXPanel createControlPanelFor(JXCollapsiblePane collapsiblePane)

      { JXPanel collapsiblePaneControlPanel = new JXPanel(); collapsiblePaneControlPanel.setOpaque(false); collapsiblePaneControlPanel.add(new JXLabel("JXCollapsiblePane")); collapsiblePaneControlPanel.add(Box.createHorizontalBox()); collapsiblePaneControlPanel.add(new JXButton(collapsiblePane.getActionMap().get(JXCollapsiblePane.TOGGLE_ACTION))); return collapsiblePaneControlPanel; }

      protected static void addSomeTranslucentContentTo(Container container)

      { container.setLayout(new VerticalLayout()); JXLabel label = new JXLabel("Some content"); label.setOpaque(false); container.add(label); JXTextField textField = new JXTextField("Write something (if you want to)"); textField.setOpaque(false); container.add(textField); JXButton button = new JXButton("Does nothing"); button.setOpaque(false); button.setBackgroundPainter(new MattePainter(new Color(0, 0, 0, 0))); container.add(button); }

      }

        Activity

        Hide
        Karl Schaefer added a comment -

        SWINGX-1435: Fix opacity issues with JXTitledPanel, making it's content pane opaque by default. Fix opacity issues with JXTaskPane, making it and it's internal collaspible pane non-opaque by default, while it's content pane continues to be opaque by default.

        swingx-core/src/main/java/org/jdesktop/swingx/plaf/basic/BasicTaskPaneUI.java
        swingx-core/src/main/java/org/jdesktop/swingx/JXTitledPanel.java
        swingx-core/src/main/java/org/jdesktop/swingx/JXTaskPane.java

        Committed revision 4260.

        Show
        Karl Schaefer added a comment - SWINGX-1435 : Fix opacity issues with JXTitledPanel, making it's content pane opaque by default. Fix opacity issues with JXTaskPane, making it and it's internal collaspible pane non-opaque by default, while it's content pane continues to be opaque by default. swingx-core/src/main/java/org/jdesktop/swingx/plaf/basic/BasicTaskPaneUI.java swingx-core/src/main/java/org/jdesktop/swingx/JXTitledPanel.java swingx-core/src/main/java/org/jdesktop/swingx/JXTaskPane.java Committed revision 4260.

          People

          • Assignee:
            Karl Schaefer
            Reporter:
            dsmania
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: