import com.sun.awt.AWTUtilities;
import java.awt.*;
import java.util.List;
import java.util.*;
import javax.swing.*;
public class TransparentSlideDialog1 extends JDialog {
private Panel panel;
private int widthLimit;
private int heightLimit;
public TransparentSlideDialog1() {
panel = new Panel();
getContentPane().add(panel);
}
public void setDialogSize(int w, int h) {
widthLimit = w;
heightLimit = h;
setSize(w, h);
}
private class Panel extends JPanel implements Runnable {
private Thread runner;
private boolean stop;
private int width;
private int height;
public Panel() {
setLayout(null);
setOpaque(false);
width = 0;
height = 50;
}
public void paintComponent(Graphics g) {
int arc = 20;
Paint p = new GradientPaint(0.0f, 0.000f, new Color(0, 0, 0, 240), width - 50, height - 50, new Color(0, 0, 0, 255), true);
Graphics2D g2 = (Graphics2D) g.create();
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2.setPaint(p);
g2.fillRoundRect(getX() + 20, getY() + 35, width - 50, height - 50, arc, arc);
g2.setStroke(new BasicStroke(2f));
g2.setColor(new Color(150, 150, 150, 255));
g2.drawRoundRect(getX() + 20, getY() + 35, width - 50, height - 50, arc, arc);
}
public void open() {
runner = new Thread(this);
runner.start();
}
public void run() {
while (!stop) {
if (width <= getWidth()) {
width += 5;
}
if (height <= getHeight() && width >= getWidth()) {
height += 3;
}
if (height >= heightLimit && width >= widthLimit) {
runner.interrupt();
stop = true;
}
repaint();
try {
Thread.sleep(2);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
e.printStackTrace();
}
}
}
}
public synchronized void openSlidePanel() {
panel.open();
}
public static void main(String[] args) {
final TransparentSlideDialog1 d = new TransparentSlideDialog1();
d.setDialogSize(1200, 640);
d.openSlidePanel();
d.setModal(true);
d.setLocationRelativeTo(null);
d.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
d.setUndecorated(true);
AWTUtilities.setWindowOpaque(d, false);
d.setVisible(true);
}
}