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;
|
}
|
|
|
|
}
|