Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4261116

Transparent JTabbedPane doesn't fill in content area

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 1.2.2
    • Fix Version/s: 1.4.0
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      beta
    • CPU:
      generic
    • OS:
      generic

      Description



      Name: rlT66838 Date: 08/09/99


      I'd like to make my JTabbedPane transparent, so the background shows up in the area around the tabs (e.g. the area to the right of the tabs, when the tabs are in the upper-left corner). But when I do this, the tabbed pane's content area becomes transparent too. This is not the right thing - it breaks the abstraction that this is an actual panel that other things can be placed on. It now looks like it's got a hole in the middle. What's more, if I try to get rid of the hole by placing an opaque JPanel on each tab pane, there's a ring of transparency around each of my JPanels. This seems to be a no-man's land which is not painted either by the JTabbedPane or its contents.

      import javax.swing.*;
      import java.awt.*;

      public class TabTest2
      {
      public final static void main (String[] args)
      {
      // Create frame
      JFrame f = new JFrame("hi");
      f.setBounds(100,100,400,400);
      JPanel p = new JPanel();
      p.setBackground(Color.red);
      p.setLayout(null);
      f.getContentPane().add(p);

      // Create tab pane
      JTabbedPane t = new JTabbedPane();
      t.setBounds(50, 50, 300, 200);
      JLabel x = new JLabel("transparent");
      x.setOpaque(false);
      t.addTab("transparent", x);
      JLabel y = new JLabel("opaque");
      y.setOpaque(true);
      t.addTab("opaque", y);
      p.add(t);

      // Show the frame.
      f.show();
      }
      }
      (Review ID: 93708)
      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                amfowler Anne Fowler (Inactive)
                Reporter:
                rlewis Roger Lewis (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: