Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.awt.*;
import java.awt.MultipleGradientPaint.CycleMethod;
import java.awt.geom.*;
import java.awt.image.*;

public class Main {
    /**
     * Creates a nifty looking inner shadow for the window.
     * @param width The width of the shadow.
     * @param height The height of the shadow.
     * @return The translucent shadow that was created.
     */
    public static BufferedImage genInnerShadow(int width, int height) {
        BufferedImage shadowOuter = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
        Graphics g = shadowOuter.getGraphics();
        Graphics2D g2 = (Graphics2D) g;
        Point2D center = new Point2D.Float(width / 2, height / 2);
        float radius = width;
        Point2D focus = new Point2D.Float(width / 2, height / 2);
        float[] dist = { 0.0f, 1.0f };
        Color[] colors = { new Color(0, 0, 0, 0), new Color(0, 0, 0, 220) };
        RadialGradientPaint p = new RadialGradientPaint(center, radius, focus, dist, colors, CycleMethod.NO_CYCLE);
        g2.setPaint(p);
        g2.fillRect(0, 0, width, height);
        return shadowOuter;
    }
}