import javax.swing.JFrame;
import javax.swing.JSlider;
import javax.swing.event.ChangeEvent;
import com.sun.awt.AWTUtilities;
public class TransparentFrame extends JFrame {
public TransparentFrame() {
setTitle("Transparent Frame");
setSize(400,400);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JSlider slider = new JSlider(JSlider.HORIZONTAL, 10, 100, 50);
add(slider);
setVisible(true);
}
public static void main(String[] args) {
new TransparentFrame();
}
public void stateChanged(ChangeEvent e) {
JSlider slider = (JSlider) e.getSource();
if(!slider.getValueIsAdjusting()){
AWTUtilities.setWindowOpacity(TransparentFrame.this, slider.getValue()/100f);
}
}
}