wenzheng.yang
2023-06-19 8d3a46d346ef028acc16e267fe5c812c76a754e5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
package publicclass;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
/**×Ô¶¯¹Ø±ÕµÄ¶Ô»°¿ò*/
import java.util.Timer;
import java.util.TimerTask;
import javax.swing.ImageIcon;
import javax.swing.JDialog;
import javax.swing.JOptionPane;
public class AutoCloseDialog {
 
    static boolean ok=true;
    /**2ÃëÖÓÏûʧµÄ¶Ô»°¿ò*/
    public static JOptionPane getDialog(String message) {
        JOptionPane op = new JOptionPane(message,JOptionPane.INFORMATION_MESSAGE);
        JDialog dialog = op.createDialog("ÌáʾÐÅÏ¢, 2Ãë×Ô¶¯¹Ø±Õ...");
        // ´´½¨Ò»¸öмÆÊ±Æ÷
        Timer timer = new Timer();
        dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
        dialog.setAlwaysOnTop(true);
        dialog.setModal(false);
        dialog.setVisible(true);
        op.setIcon(new ImageIcon("image/icon/sosicon.png"));
        dialog.setIconImage(new ImageIcon("image/icon/versionicon.png").getImage());
        // 3ÃëºóÖ´ÐиÃÈÎÎñ
        timer.schedule(new TimerTask() {
            public void run() {
                dialog.dispose();
                
            }
        }, 2000);
        
        dialog.addWindowListener(new WindowListener() {
            
            @Override
            public void windowOpened(WindowEvent e) {
                ok=false;
                
            }
            
            @Override
            public void windowIconified(WindowEvent e) {
                // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù
                
            }
            
            @Override
            public void windowDeiconified(WindowEvent e) {
                // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù
                
            }
            
            @Override
            public void windowDeactivated(WindowEvent e) {
                // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù
                
            }
            
            @Override
            public void windowClosing(WindowEvent e) {
                // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù
                
            }
            
            @Override
            public void windowClosed(WindowEvent e) {
                ok=true;
                
            }
            
            @Override
            public void windowActivated(WindowEvent e) {
                // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù
                
            }
        });
        return op;
    }
 
 
    /**24hÏûʧµÄ¶Ô»°¿ò*/
    public static JOptionPane getDialogno(String message) {
        JOptionPane op = new JOptionPane(message,JOptionPane.INFORMATION_MESSAGE);
        final JDialog dialog = op.createDialog("ÌáʾÐÅÏ¢£¡");
 
        // ´´½¨Ò»¸öмÆÊ±Æ÷
        Timer timer = new Timer();
 
        // 3ÃëºóÖ´ÐиÃÈÎÎñ
        timer.schedule(new TimerTask() {
            public void run() {
                dialog.dispose();
            }
        }, 86400000);
        dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
        dialog.setAlwaysOnTop(true);
        dialog.setModal(false);
        dialog.setVisible(true);
        op.setIcon(new ImageIcon("image/icon/sosicon.png"));
        op.setIcon(new ImageIcon("image/icon/versionicon.png"));
dialog.addWindowListener(new WindowListener() {
            
            @Override
            public void windowOpened(WindowEvent e) {
                
            }
            
            @Override
            public void windowIconified(WindowEvent e) {
                // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù
                
            }
            
            @Override
            public void windowDeiconified(WindowEvent e) {
                // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù
                
            }
            
            @Override
            public void windowDeactivated(WindowEvent e) {
                // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù
                
            }
            
            @Override
            public void windowClosing(WindowEvent e) {
                // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù
                
            }
            
            @Override
            public void windowClosed(WindowEvent e) {
                            
            }
            
            @Override
            public void windowActivated(WindowEvent e) {
                // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù
                
            }
        });
        return op;
    }
 
 
    public static boolean isOk() {
        return ok;
    }
 
 
    public static void setOk(boolean ok) {
        AutoCloseDialog.ok = ok;
    }
 
}