1. GradientPaint coderanch.com |
2. Using GradientPaint and Swing Components coderanch.comHere's some example code I made for a JPanel that has a GradientPaint background... Hopefully this helps you out... import java.awt.*; import java.awt.geom.*; import javax.swing.*; public class GradientPanel extends JPanel { protected boolean isDark; public GradientPanel( LayoutManager layout, boolean isDoubleBuffered ) { super( layout, isDoubleBuffered ); setOpaque( true ); setDark( false ); } public GradientPanel( LayoutManager layout ) { this( layout, ... |
3. GradientPaint problem coderanch.comI'm using the following code to paint my canvas: public void paint(Graphics g) { Graphics2D g2 = (Graphics2D)g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //fill Rectangle int xPos1 = 0; int yPos1 = 0; int xPos2 = canvasWidth / 6; int yPos2 = canvasHeight / 8; GradientPaint gradientPaint = new GradientPaint(xPos1, yPos1, Color.yellow, xPos2, yPos2, Color.orange); g2.setPaint(gradientPaint); g2.fill(new Rectangle(canvasWidth, canvasHeight)); //draw title g2.setPaint(Color.white); g2.setFont(f); int ... |
4. GradientPaint problem coderanch.comHi everyone I am creating a program for both Windows XP and Vista. I just got my hands on a new laptop with Vista and a wide screen display. Hence the problem with regards to gradient painting. I have programmed some gradient paint for the toolbar background. It is composed of very thin alternating lines running diagonally. The lines are very ... |