zsh_root
2024-01-02 7b595546af704983dbafcd0d385c8768ddacefc2
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
package Method;
import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
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.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
 
import ColorAndFont.ChooseFont;
import ColorAndFont.UIColor;
import PbuliClass.JButtonModel;
public class TimeDialog   extends JDialog implements WindowListener {
 
    /**
     * 
     */
    private static final long serialVersionUID = 1L;
    Timer timer;
    int i=0;
    JTextArea are=null;
    JScrollPane gd=null;
    JButtonModel jbt_sure=null;
 
 
    public  TimeDialog(String text) {
        String name="ÐÅÏ¢Ìáʾ¿ò3Ãëºó×Ô¶¯¹Ø±Õ...";
        Toolkit toolkit = getToolkit();// »ñµÃ´°Ì幤¾ß°ü
        Dimension screenSize = toolkit.getScreenSize();// »ñÈ¡ÆÁÄ»´óС
        int width =screenSize.width;// ¼ÆËã´°Ìåпí¶È
        int x0=(width-500)/2;//´°Ìåx0×ø±ê
        int y0=100;//´°Ìåy0×ø±ê
        Container rq=getContentPane();
        rq.setBackground(UIColor.getBlues());
        rq.add(getJp_mb());
        this.setAlwaysOnTop(true);
        this.setTitle(name);
        this.setBounds(x0, y0,400,250);
        this.setVisible(true);
        this.setIconImage(new ImageIcon("image/icon/versionicon.png").getImage());
        this.setModal(true);
        this.setAlwaysOnTop(true);//×ÜÊÇÖö¥
        ding_shi_qi();
        AutoCloseDialog.setOk(false);
        are.setText(text);
 
    }
 
    public void close() {
        AutoCloseDialog.setOk(true);
        this.dispose();
    }
 
 
 
    public JPanel getJp_mb() {
        JPanel jp_mb=new JPanel();
        jp_mb.setLayout(null);
        jp_mb.setBackground(Color.white);        
        getGd().setBounds(10,0,360,150);
        getJbt_sure().setBounds(10,155,360,40);
        jp_mb.add(gd);
        jp_mb.add(jbt_sure);
        jp_mb.addMouseListener(new MouseListener() {
            public void mouseReleased(MouseEvent e) {
            }
 
            @Override
            public void mousePressed(MouseEvent e) {
                close();
            }
 
            @Override
            public void mouseExited(MouseEvent e) {
 
            }
 
            @Override
            public void mouseEntered(MouseEvent e) {
            }
 
            @Override
            public void mouseClicked(MouseEvent e) {
                close();
            }
 
        });
        return jp_mb;
    }
 
 
 
    @Override
    public void windowOpened(WindowEvent e) {
    }
 
    @Override
    public void windowClosing(WindowEvent e) {
    }
 
    @Override
    public void windowClosed(WindowEvent e) {
 
    }
 
    @Override
    public void windowIconified(WindowEvent e) {
        // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù
 
    }
 
    @Override
    public void windowDeiconified(WindowEvent e) {
        // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù
 
    }
 
    @Override
    public void windowActivated(WindowEvent e) {
        AutoCloseDialog.setOk(false);
 
    }
 
    @Override
    public void windowDeactivated(WindowEvent e) {
        // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù
 
    }
 
 
    /**¶¨Ê±Æ÷*/
    public  void ding_shi_qi() {
        AutoCloseDialog.setOk(false);
        Integer cacheTime =1000;
        timer = new Timer(); 
        timer.schedule(new TimerTask() { 
            @Override  
            public void run() { 
                try {
                    i++;
                    if(i==3) {
                        close();
                        i=0;
                        timer.cancel();
                    }
 
                } catch (Exception e) {
                    // TODO ×Ô¶¯Éú³ÉµÄ catch ¿é
                    e.printStackTrace();
                }  
            }  
        }, 1000, cacheTime);  
 
    }
 
    public JButtonModel getJbt_sure() {
        if(jbt_sure==null) {
            jbt_sure=new JButtonModel("¹Ø±Õ");
            jbt_sure.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    close();
                    timer.cancel();
                }
            });
        }
        return jbt_sure;
    }
 
    public JTextArea getAre() {
        if(are==null) {
            are=new JTextArea();
            are.setForeground(Color.red);
            are.setFont(ChooseFont.getFont(14));
            are.setEditable(false);
        }
        return are;
    }
 
    public JScrollPane getGd() {
        if(gd==null) {
            gd=new JScrollPane(getAre());
            gd.setBorder(null);
        }
        return gd;
    }
 
 
 
}