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

Metal L&F: JTabbedPane.setBackgroundAt() does not work

XMLWordPrintable

    • swing1.1
    • generic
    • generic
    • Verified


      JTabbedPane.setBackgroundAt() does not work.

      The following application attempts to display one tab out of 5 with
      a magenta background. When the app is executed, the tab is displayed with
      the default background, and not with the expected magenta background.
      The background of the tab is not set to magenta even when it is selected.
      ==========================================================================

      /*
       * tabTest.java
       * JTabbedPane.setBackgroundAt() does not work
       *
      */

      import java.awt.*;
      import java.awt.event.*;
      import java.awt.swing.*;

      public class tabTest extends JFrame {

        JTabbedPane tabbedPane;
        
        public tabTest()
          {
            
            tabbedPane = new JTabbedPane();
            for (int i = 0; i < 5; i++)
      {
      JPanel panel = new JPanel();
      panel.add(new JLabel("The tab titled 'Tab2' should have a magenta background, but doesn't."));
      tabbedPane.addTab("Tab" + i, panel);
      }

            tabbedPane.setSelectedIndex(2);
            tabbedPane.setBackgroundAt(2,Color.magenta);
            tabbedPane.setForegroundAt(1,Color.green);
            
            getContentPane().setLayout(new BorderLayout());
            getContentPane().add("Center", tabbedPane);
          }

        public static void main(String[] args)
          {
            tabTest frame = new tabTest();
            frame.pack();
            frame.setSize(500,350);
            frame.show();
          }
        
      }


            tsantossunw Tom Santos (Inactive)
            gaurisha Gauri Sharma (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: