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

Not able to paint the graphics with GradientPaint color.

    • 2d
    • sparc
    • solaris_10

      FULL PRODUCT VERSION :
      java version "1.8.0_45"


      ADDITIONAL OS VERSION INFORMATION :
      SunOS NMSServer 5.10 Generic_150400-23 sun4u sparc SUNW,SPARC-Enterprise


      A DESCRIPTION OF THE PROBLEM :
      Painting the graphics with GradientPaint is not painted the GradientPaint color, instead it is painting black color.

      this problem is exist in latest solaries envs
      SunOS IMAPV3S011 5.10 Generic_150400-17 sun4v sparc SUNW,SPARC-Enterprise-T5220
      SunOS NMSServer 5.10 Generic_150400-23 sun4u sparc SUNW,SPARC-Enterprise

      Not exist in
       SunOS solaris-187 5.10 Generic_142909-17 sun4v sparc sun4v
      SunOS solaris-91 5.10 Generic_142909-17 sun4v sparc sun4v

      This problem is not exist with jre1.6_31 also

      This problem not exist in windows os also

      REGRESSION. Last worked in version 6u45

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile and run the attached source code in problem solarise and non problem solaries env .

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Tabs should paint with gradient paint color
      ACTUAL -
      Tabs are not paint with gradient paint color

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.Color;
      import java.awt.Dimension;
      import java.awt.FlowLayout;
      import java.awt.GradientPaint;
      import java.awt.Graphics;
      import java.awt.Graphics2D;
      import java.awt.Paint;

      import javax.swing.JFrame;
      import javax.swing.JPanel;
      import javax.swing.JTabbedPane;
      import javax.swing.SwingUtilities;
      import javax.swing.plaf.basic.BasicTabbedPaneUI;

      public class TabbedPaneDemo1
      {
          public static void main(String[] args)
          {
              final JFrame frame = new JFrame("TabbedPaneDemo");
              frame.setSize(300 , 400);
              frame.setLayout(new FlowLayout());
              JPanel panel = new JPanel();
              JTabbedPane pane = new JTabbedPane(JTabbedPane.TOP ,
                      JTabbedPane.SCROLL_TAB_LAYOUT);
              pane.setPreferredSize(new Dimension(250 , 350));
              pane.setUI(new MyTabpaneUI());
              pane.addTab("Tab1" , new JPanel());
              pane.addTab("Tab2" , new JPanel());
              panel.add(pane);
              frame.add(panel);
              frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
              SwingUtilities.invokeLater(new Runnable()
              {

                  @Override
                  public void run()
                  {
                      frame.setVisible(true);
                  }
              });

          }

      }

      class MyTabpaneUI extends BasicTabbedPaneUI
      {
          protected void paintTabBackground(Graphics g , int tabPlacement ,
                  int tabIndex , int x , int y1 , int w , int h , boolean isSelected)
          {
              super.paintTabBackground(g , tabPlacement , tabIndex , x , y1 , w , h ,
                      isSelected);
              if (isSelected)
              {
                  Paint paint = new GradientPaint(x , y1 , Color.white , x + w , y1
                          + h , Color.BLUE , true);

                  Graphics2D g2D = (Graphics2D) g;
                  g2D.setPaint(paint);
                  g2D.fillRect(x , y1 , w , h);
              }

          }

      }

      ---------- END SOURCE ----------

            prr Philip Race
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: