⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 timerdialog.java

📁 JAVA做的QQ软件,感兴趣的可以看看,收藏依旧
💻 JAVA
字号:
import java.awt.BorderLayout;
import javax.swing.JPanel;
import javax.swing.JDialog;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JFrame;
import javax.swing.ImageIcon;
import java.awt.event.*;

public class TimerDialog extends JDialog implements Runnable {

	private JPanel jContentPane = null;
	private JButton okButton = null;
	private JLabel msgLabel = null;
	private Thread t;
	private int time;
	private JLabel iconLabel = null;
	private JFrame fFrame = null;	

	private JButton getOkButton() {
		if (okButton == null) {
			okButton = new JButton();
			okButton.setBounds(new java.awt.Rectangle(85,53,115,28));
			okButton.setText("确   定");
			okButton.setForeground(new java.awt.Color(255,102,102));
			okButton.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD, 14));
			okButton.setBackground(new java.awt.Color(197,234,252));
			okButton.setSelected(true);
			okButton.addActionListener(new ActionListener()
					{
						public void actionPerformed(ActionEvent e)
						{
							dispose();
							fFrame.dispose();
						}
					}
					
			);
		}
		return okButton;
	}	
	public TimerDialog(JFrame fatherFrame,boolean model,String inMsg) {
		super(fatherFrame,model);
		initialize(inMsg,fatherFrame);
		try
		{
			t=new Thread(this);
			t.start();
			
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
	}

	
	private void initialize(String inMsg,JFrame inFrame) {
		this.fFrame = inFrame;
		this.setContentPane(getJContentPane());
		msgLabel.setText(inMsg);
		this.setSize(301, 120);
		this.setModal(false);
		this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
		this.setResizable(false);
		this.setTitle("Fetion消息窗口");
		this.setVisible(true);		
		this.setLocationRelativeTo(null);
		
	}

	
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			iconLabel = new JLabel();
			iconLabel.setIcon(new ImageIcon(getClass().getResource("/pictures/msg.JPG")));
			iconLabel.setLocation(new java.awt.Point(18,13));
			iconLabel.setSize(new java.awt.Dimension(27,27));
			iconLabel.setText("");
			msgLabel = new JLabel();
			msgLabel.setBounds(new java.awt.Rectangle(57,15,218,25));
			msgLabel.setFont(new java.awt.Font("楷体_GB2312", java.awt.Font.BOLD, 14));
			msgLabel.setForeground(java.awt.Color.blue);
			msgLabel.setToolTipText("");
			msgLabel.setText("");
			jContentPane = new JPanel();
			jContentPane.setLayout(null);
			jContentPane.setBackground(new java.awt.Color(245,255,255));
			jContentPane.add(getOkButton(), null);
			jContentPane.add(msgLabel, null);
			jContentPane.add(iconLabel, null);
		}
		return jContentPane;
	}
	public void run()
	{
		for(time=10;time>0;time--)
		{			
			okButton.setText("确  定(" + Integer.toString(time) + ")");
			try 
			{
				t.sleep(1000);
			} 
			catch (Exception e) 
			{
				System.out.println("倒计时异常:" + e);
				e.printStackTrace();
			}
		}		
		dispose();
		fFrame.dispose();
	}
	public static void main(String[] args)
	{
		new TimerDialog(new JFrame(),false,"jjjjjjjjjjjjjjjjjjjjjjjjjj");
	}
} 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -