Here you can find the source of fadeIn(final JDialog dialog)
public static void fadeIn(final JDialog dialog)
//package com.java2s; //License from project: Open Source License import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JDialog; import javax.swing.Timer; public class Main { /**//from w w w . j av a2 s . c o m * Creates an animation to fade the dialog opacity from 0 to 1. */ public static void fadeIn(final JDialog dialog) { final Timer timer = new Timer(10, null); timer.setRepeats(true); timer.addActionListener(new ActionListener() { private float opacity = 0; @Override public void actionPerformed(ActionEvent e) { opacity += 0.15f; dialog.setOpacity(Math.min(opacity, 1)); if (opacity >= 1) timer.stop(); } }); dialog.setOpacity(0); timer.start(); dialog.setVisible(true); } }