I was bored, so here's a test case... I can see the banding, just barely.  I 
suppose some monitors will make it look worse than others.  In any case I think 
the solution is dithering, but you will have to do it manually, simply 
supplying the rendering hint 
(g2.setRenderingHint(RenderingHints.KEY_DITHERING,RenderingHints.VALUE_DITHER_ENABLE);
 ) doesn't seem to have an effect on the behavior of GradientPaint.

[code]
/*
 * Gradient.java
 *
 * Created on June 5, 2006, 10:29 PM
 *
 */

package scott.palmer;

import java.awt.Color;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import javax.swing.JFrame;
import javax.swing.JPanel;

/**
 *
 * @author Scott Palmer
 */
public class Gradient extends JPanel
{
        public static void main(String [] args)
        {
                JFrame f = new JFrame("Gradient with Banding issues");
                f.setContentPane(new Gradient());
                f.setSize(800,200);
                f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                f.setVisible(true);
        }

        protected void paintComponent(Graphics g)
        {
                Graphics2D g2 = (Graphics2D) g;
                g2.setPaint(new GradientPaint(
                                0,0,new Color(101,101,101),
                                getWidth(),0,new Color(130,130,130)));
                g2.fillRect(0,0,getWidth(),getHeight());
        }
}
[/code]
[Message sent by forum member 'swpalmer' (swpalmer)]

http://forums.java.net/jive/thread.jspa?messageID=119469

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to