Java Graphics Draw Gradient paintListGradientSelection(Graphics2D graphics2D, Component component, int width, int height)

Here you can find the source of paintListGradientSelection(Graphics2D graphics2D, Component component, int width, int height)

Description

paint List Gradient Selection

License

Open Source License

Declaration

public static void paintListGradientSelection(Graphics2D graphics2D, Component component, int width,
            int height) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2011 Zeljko Zirikovic.//from   w w w.  ja va2s  .c om
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GPL which 
 * accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/gpl.html
 ******************************************************************************/

import java.awt.Color;
import java.awt.Component;
import java.awt.GradientPaint;
import java.awt.Graphics2D;

public class Main {
    private static Color LIST_TOP_LINE_COLOR = new Color(255, 235, 180);
    private static Color LIST_TOP_GRADIENT_COLOR = new Color(255, 243, 186);
    private static Color LIST_BOTTOM_GRADIENT_COLOR = new Color(255, 223, 166);

    public static void paintListGradientSelection(Graphics2D graphics2D, Component component, int width,
            int height) {
        paintGradientSelection(LIST_TOP_LINE_COLOR, LIST_BOTTOM_GRADIENT_COLOR, LIST_TOP_GRADIENT_COLOR,
                LIST_BOTTOM_GRADIENT_COLOR, graphics2D, width, height);
    }

    private static void paintGradientSelection(Color topLineColor, Color bottomLineColor, Color topGradientColor,
            Color bottomGradientColor, Graphics2D graphics2D, int width, int height) {
        GradientPaint paint = new GradientPaint(0, 1, topGradientColor, 0, height - 2, bottomGradientColor);

        graphics2D.setPaint(paint);
        graphics2D.fillRect(0, 0, width, height);

        graphics2D.setColor(topLineColor);
        graphics2D.drawLine(0, 0, width, 0);

        graphics2D.setColor(bottomLineColor);
        graphics2D.drawLine(0, height - 1, width, height - 1);
    }
}

Related

  1. DrawGradient(Graphics g, int x, int y, int width, int height, Color color1, Color color2)
  2. linearGradient(final JComponent comp, final Color col, final int step, final int sleepTime)
  3. paintGradient(Graphics g, JComponent comp, Color color1, Color color2)
  4. paintGradientSelection(Color topLineColor, Color bottomLineColor, Color topGradientColor, Color bottomGradientColor, Graphics2D graphics2D, int width, int height)
  5. paintHorizontalGradient2D(Graphics2D g, int x, int y, int w, int h, float g1, float g2, Color c1, Color c2, Color c3, int[][] mask)
  6. paintMacGradientFill(Graphics2D g, Rectangle rect, Color brightC, Color darkC)
  7. paintVerticalGradient2D(Graphics2D g, int x, int y, int w, int h, float g1, float g2, Color c1, Color c2, Color c3, int[][] mask)