|
- import java.awt.EventQueue;
- import javax.swing.JButton;
- import javax.swing.JFrame;
- import javax.swing.JSlider;
- import javax.swing.event.ChangeEvent;
- import javax.swing.event.ChangeListener;
- import com.sun.awt.AWTUtilities;
- public class DemoFrame extends JFrame {
- private JSlider slider;
- JButton button;
- private screen screen_;
- public static void main(String args[]) {
- EventQueue.invokeLater(new Runnable() {
- public void run() {
- try {
- setDefaultLookAndFeelDecorated(true);
- DemoFrame frame = new DemoFrame();
- frame.setVisible(true);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- }
- public DemoFrame() {
- super();
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- initComponents();
- }
- private void initComponents() {
- // 省略界面代码
- }
- private class SliderChangeListener implements ChangeListener {
- public void stateChanged(final ChangeEvent e) {
- float v = slider.getValue() / 100f;
- AWTUtilities.setWindowOpacity(DemoFrame.this, v);// 设置窗体的透明度v
- }
- }
- }
复制代码 |
|