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

📄 loginprompt.java

📁 这是一个使用Java编写的像QQ一样的即时通讯软件
💻 JAVA
字号:
package client;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;

import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.SpringLayout;
import javax.swing.WindowConstants;

import com.swtdesigner.SwingResourceManager;

public class LoginPrompt extends JDialog {

	/**
	 * 
	 */
	private static final long serialVersionUID = -3057570073536004935L;
	private SpringLayout springLayout;
	private JDialog loginPrompt;
	public JLabel label_1;

	/**
	 * Create the frame
	 */
	public LoginPrompt(JFrame frame) {
		super(frame);
	
		getContentPane().setBackground(new Color(207, 208, 233));
		setUndecorated(true);
		setAlwaysOnTop(true);
		setResizable(false);
		springLayout = new SpringLayout();
		getContentPane().setLayout(springLayout);
		setBounds(100, 100, 135, 84);
		setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
		
		loginPrompt = this;
		
    	Dimension dimension= Toolkit.getDefaultToolkit().getScreenSize();
    	int screenheight=dimension.height;
        int screenwidth=dimension.width;
        this.setLocation(screenwidth-this.getSize().width,screenheight);

		final JLabel label = new JLabel();
		label.setIcon(SwingResourceManager.getIcon(LoginPrompt.class, "/images/31.gif"));
		getContentPane().add(label);
		springLayout.putConstraint(SpringLayout.SOUTH, label, 55, SpringLayout.NORTH, getContentPane());
		springLayout.putConstraint(SpringLayout.NORTH, label, 21, SpringLayout.NORTH, getContentPane());
		springLayout.putConstraint(SpringLayout.EAST, label, 45, SpringLayout.WEST, getContentPane());
		springLayout.putConstraint(SpringLayout.WEST, label, 15, SpringLayout.WEST, getContentPane());

		label_1 = new JLabel();
		label_1.setText("");
		getContentPane().add(label_1);
		springLayout.putConstraint(SpringLayout.EAST, label_1, 130, SpringLayout.WEST, getContentPane());
		springLayout.putConstraint(SpringLayout.WEST, label_1, 0, SpringLayout.EAST, label);
		springLayout.putConstraint(SpringLayout.SOUTH, label_1, 47, SpringLayout.NORTH, getContentPane());
		springLayout.putConstraint(SpringLayout.NORTH, label_1, 30, SpringLayout.NORTH, getContentPane());
		
		TimerTaskExample timeTask = new TimerTaskExample();
		Timer timer = new Timer();
		timer.schedule(timeTask, 0, 15);
		
	}
	
	 class TimerTaskExample extends TimerTask{

			String hour;

			String second;

			String miniutes;

			Date date;	
			
			public TimerTaskExample(){
			}
			@Override
			public void run() {
				Dimension dimension= Toolkit.getDefaultToolkit().getScreenSize();
		    	int screenheight=dimension.height;
		        //int screenwidth=dimension.width;
		        loginPrompt.setLocation(loginPrompt.getLocation().x, loginPrompt.getLocation().y-1);
				if(loginPrompt.getLocation().y < screenheight-loginPrompt.getSize().height){
					this.cancel();
					getContentPane().addMouseListener(new MouseAdapter() {
						public void mousePressed(final MouseEvent e) {
							loginPrompt.dispose();
						}
					});
				}
			}
			
		}
	    

}


⌨️ 快捷键说明

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