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

REGRESSION: Gradient Button Background not working with jdk 1.5.working in 1.4

    XMLWordPrintable

    Details

      Description

      FULL PRODUCT VERSION :
      java version "1.5.0_03"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_03-b07)
      Java HotSpot(TM) Client VM (build 1.5.0_03-b07, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Window XP

      A DESCRIPTION OF THE PROBLEM :
      cannot paint JButton background with gradient color.. even after overriding jbutton paintComponent method, calling super.paintComponent() and setting the jbutton.setOpaque(false)

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Extend jbutton class and override the paintcomponent method with your own gradient paint.

      Make instances of of the GradientButton class and add to the jpanel and to JFrame.

      The expected gradient background is not visible.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      the expected result is painting a gradient background from white to green as a button background.
      ACTUAL -
      it shows the default ocean l&f blue gradient background of jbutton

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      no error messages

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.*;
      import javax.swing.*;
       
      public class GradientButton extends JButton {


      public static void main(String args[]) {
      JFrame frame = new JFrame();
      frame.setSize(600,400);

      GradientButton button = new GradientButton(){
      public void paintComponent(Graphics g) {
      final Graphics2D g2 = (Graphics2D) g;
      int w = getWidth();
      int h = getHeight();
      GradientPaint gradient = new GradientPaint(20, 0, Color.white, 20, h, Color.green,
      false);
      g2.setPaint(gradient);
      g2.fillRect(0, 0, w, h);

      super.paintComponent(g);
      }
      };
      button.setText("Test");
      button.setOpaque(false);

      frame.getContentPane().add(button);
      frame.pack();
      frame.setVisible(true);
      }
      }


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

      CUSTOMER SUBMITTED WORKAROUND :
      no method found

      Release Regression From : 1.4.2_05
      The above release value was the last known release where this
      bug was known to work. Since then there has been a regression.

        Attachments

          Activity

            People

            Assignee:
            shickeysunw Shannon Hickey (Inactive)
            Reporter:
            jssunw Jitender S (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: