aaaaaaaaaaaaaaaaaaaahttp://yuncode.net//**
* 登陆过程中的动画界面
*/
package cn.qq.view.login;
import java.awt.AWTException;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.SystemTray;
import java.awt.TrayIcon;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.geom.RoundRectangle2D;
import java.io.IOException;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import com.sun.awt.AWTUtilities;
import cn.qq.listener.FrameMoveListener;
import cn.qq.listener.WindowCloseListener;
import cn.qq.listener.WindowMinListener;
import cn.qq.manager.ServiceInterface;
import cn.qq.service.LoginRequest;
import cn.qq.thread.LoginTrayIconThread;
import cn.qq.view.util.JButtonUtil;
/**
*
* @author _zc
*
*/
public class LoadingFrame extends JFrame implements Runnable {
private JPanel mainPane = null; // 主面板
private JPanel downPane = null; // 底部取消按钮面板
private JLabel lblCancel = null; // 取消文字标签
private JButton btnCancelLogin = null;// 取消登陆按钮
private JButton btnMin = null; // 最小化
private JButton btnClose = null;// 关闭
private JButton btnSet = null;// 设置
private JLabel lblAccountInfo = null;// 提示账号
public SystemTray sysTray = null; // 系统托盘
public TrayIcon trayIcon = null; // 托盘图标
public LoginFrame loginFrame = null; // 登录界面
boolean isRun = true; // 控制线程
public LoadingFrame(LoginFrame loginFrame) {
this.loginFrame = loginFrame;
}
public void launchFrame() {
this.setSize(380, 292);
this.setIconImage(new ImageIcon("image/Login/qqTitle.png").getImage());
this.setUndecorated(true);
AWTUtilities.setWindowOpacity(this, 0.98f);
this.initComponent();
this.addComponent();
this.initSystemTray();
this.setContentPane(mainPane);
/** 设置圆角 */
AWTUtilities.setWindowShape(this, new RoundRectangle2D.Double(
0.0D, 0.0D, this.getWidth(), this.getHeight(), 20.0D, 20.0D));
// 添加窗口移动监听
FrameMoveListener listener = new FrameMoveListener(this);
this.addMouseListener(listener);
this.addMouseMotionListener(listener);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
try {
Thread.sleep(4000);
} catch (InterruptedException e1) {
e1.printStackTrace();
}
//多账号登录登录请求
if(AddLoginAccountFrame.account!=null && !AddLoginAccountFrame.account.equals("")){
LoginRequest service = null;
try {
service = new LoginRequest(AddLoginAccountFrame.account, AddLoginAccountFrame.password, this);
} catch (IOException e) {
this.showTip();
// e.printStackTrace();
}
service.sendServiceRequest();
service.updateInfo();
}
//向服务器发送登陆请求
ServiceInterface request = null;
try {
request = new LoginRequest(this);
} catch (IOException e) {
this.showTip();
// e.printStackTrace();
}
if(request != null){
request.sendServiceRequest();
request.updateInfo();
}
}
/**
* 显示提示消息
*/
public void showTip() {
this.setVisible(false);
this.dispose();
this.sysTray.remove(this.trayIcon);
this.loginFrame.setVisible(true);
try {
this.loginFrame.sysTray.add(loginFrame.trayIcon);
} catch (AWTException e1) {
// TODO Auto-generated catch block
// e1.printStackTrace();
}
this.loginFrame.setLocation(this.getX(),this.getY());
this.loginFrame.mainPane.remove(this.loginFrame.downPane);
this.loginFrame.mainPane.add(this.loginFrame.errorTipPane);
this.loginFrame.errorTipPane.setBounds(0, 241, 380, 51);
this.loginFrame.errorTipPane.lblTip.setText("网络连接故障,服务器正在维护。");
this.loginFrame.errorTipPane.lblTip.setBounds(100, 15, 300, 20);
this.loginFrame.mainPane.updateUI();
}
/**
* 设置系统托盘
*/
private void initSystemTray() {
sysTray = SystemTray.getSystemTray();
trayIcon = new TrayIcon(new ImageIcon("image/Loading/login_tray/6.png").getImage(),"QQ登录");
LoginTrayIconThread trayIconThread = new LoginTrayIconThread(trayIcon);
new Thread(trayIconThread).start();
try {
if (SystemTray.isSupported() && trayIcon != null) {
sysTray.add(trayIcon);
}
} catch (AWTException e1) {
e1.printStackTrace();
}
}
/**
* 初始化组件
*/
private void initComponent() {
// 主面板
mainPane = new MainPane();
// mainPane.setBorder(new LineBorder(Color.GRAY));
downPane = new DownPane();
lblAccountInfo = new JLabel(loginFrame.getJtfAccount().getText() + "正在登录...");
lblAccountInfo.setFont(new Font("微软雅黑", Font.PLAIN, 12));
lblAccountInfo.setForeground(Color.black);
btnClose = JButtonUtil.getBtnClose();
btnMin = JButtonUtil.getBtnMin();
btnSet = JButtonUtil.getBtnSet();
btnSet.setEnabled(false);
// 给取消按钮添加活动事件
btnCancelLogin.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
setVisible(false);
isRun = false;
dispose();
sysTray.remove(trayIcon);
loginFrame.setVisible(true);
try {
loginFrame.sysTray.add(loginFrame.trayIcon);
} catch (AWTException e1) {
e1.printStackTrace();
}
loginFrame.setLocation(LoadingFrame.this.getX(),
LoadingFrame.this.getY());
}
});
// 给最小化按钮添加活动事件
btnMin.addActionListener(new WindowMinListener(this));
//给关闭按钮添加监听
btnClose.setActionCommand("exit");
btnClose.addActionListener(new WindowCloseListener(this));
}
/**
* 添加组件
*/
private void addComponent() {
mainPane.setLayout(null);
mainPane.add(btnClose);
btnClose.setBounds(342, -2, 39, 20);
mainPane.add(btnMin);
btnMin.setBounds(315, -2, 28, 20);
mainPane.add(btnSet);
btnSet.setBounds(288, -2, 28, 20);
mainPane.add(lblAccountInfo);
lblAccountInfo.setBounds(140, 115, 180, 60);
mainPane.add(downPane);
downPane.setBounds(0, 241, 380, 51);
}
/**
* 底部按钮面板
*/
class DownPane extends JPanel {
public DownPane() {
btnCancelLogin = JButtonUtil.getIconButton(
"image/Login/button_red_normal.png",
"image/Login/button_red_press.png",
"image/Login/button_red_hover.png");
lblCancel = new JLabel("取 消");
lblCancel.setFont(new Font("微软雅黑", Font.PLAIN, 12));
lblCancel.setForeground(Color.BLACK);
this.setLayout(null);
this.add(lblCancel);
lblCancel.setBounds(163, 16, 100, 25);
this.add(btnCancelLogin);
btnCancelLogin.setBounds(72, 5, 237, 48);
}
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
g.drawImage(new ImageIcon("image/Login/loginbutton_background.jpg")
.getImage(), 0, 0, 378, 50, this);
g.drawImage(new ImageIcon("image/Loading/loading.gif").getImage(),
0, 1, 380, 2, this);
}
}
/**
* 主面板
*
* @author _zc
*/
class MainPane extends JPanel implements Runnable {
int time = 1;
public MainPane() {
new Thread(this).start();
}
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.drawImage(new ImageIcon("image/Login/background/afternoon.jpg")
.getImage(), 0, 0, 380, 292, this);
// if (time <= 10) {
// g.drawImage(
// new ImageIcon("image/Loading/white/1.png").getImage(),
// 168, 165, 28, 28, this);
// } else if (time <= 20) {
// g.drawImage(
// new ImageIcon("image/Loading/white/2.png").getImage(),
// 168, 165, 28, 28, this);
// } else if (time <= 30) {
// g.drawImage(
// new ImageIcon("image/Loading/white/3.png").getImage(),
// 168, 165, 28, 28, this);
// } else if (time <= 40) {
// g.drawImage(
// new ImageIcon("image/Loading/white/4.png").getImage(),
// 168, 165, 28, 28, this);
// } else if (time <= 50) {
// g.drawImage(
// new ImageIcon("image/Loading/white/5.png").getImage(),
// 168, 165, 28, 28, this);
// } else if (time <= 60) {
// g.drawImage(
// new ImageIcon("image/Loading/white/6.png").getImage(),
// 168, 165, 28, 28, this);
// } else if (time <= 70) {
// g.drawImage(
// new ImageIcon("image/Loading/white/7.png").getImage(),
// 168, 165, 28, 28, this);
// } else if (time <= 80) {
// g.drawImage(
// new ImageIcon("image/Loading/white/8.png").getImage(),
// 168, 165, 28, 28, this);
// }
// time++;
// if (time >= 80) {
// time = 1;
// }
if (time <= 10) {
g.drawImage(
new ImageIcon("image/Loading/snow_loading/frame-000001.png").getImage(),
60, 80, 286, 50, this);
} else if (time <= 20) {
g.drawImage(
new ImageIcon("image/Loading/snow_loading/frame-000002.png").getImage(),
60, 80, 286, 50, this);
} else if (time <= 30) {
g.drawImage(
new ImageIcon("image/Loading/snow_loading/frame-000003.png").getImage(),
60, 80, 286, 50, this);
} else if (time <= 40) {
g.drawImage(
new ImageIcon("image/Loading/snow_loading/frame-000004.png").getImage(),
60, 80, 286, 50, this);
} else if (time <= 50) {
g.drawImage(
new ImageIcon("image/Loading/snow_loading/frame-000005.png").getImage(),
60, 80, 286, 50, this);
} else if (time <= 60) {
g.drawImage(
new ImageIcon("image/Loading/snow_loading/frame-000006.png").getImage(),
60, 80, 286, 50, this);
} else if (time <= 70) {
g.drawImage(
new ImageIcon("image/Loading/snow_loading/frame-000007.png").getImage(),
60, 80, 286, 50, this);
} else if (time <= 80) {
g.drawImage(
new ImageIcon("image/Loading/snow_loading/frame-000008.png").getImage(),
60, 80, 286, 50, this);
}else if (time <= 90) {
g.drawImage(
new ImageIcon("image/Loading/snow_loading/frame-000009.png").getImage(),
60, 80, 286, 50, this);
}else if (time <= 100) {
g.drawImage(
new ImageIcon("image/Loading/snow_loading/frame-000010.png").getImage(),
60, 80, 286, 50, this);
}else if (time <= 110) {
g.drawImage(
new ImageIcon("image/Loading/snow_loading/frame-000011.png").getImage(),
60, 80, 286, 50, this);
}else if (time <= 120) {
g.drawImage(
new ImageIcon("image/Loading/snow_loading/frame-000010.png").getImage(),
60, 80, 286, 50, this);
}else if (time <= 130) {
g.drawImage(
new ImageIcon("image/Loading/snow_loading/frame-000009.png").getImage(),
60, 80, 286, 50, this);
}else if (time <= 140) {
g.drawImage(
new ImageIcon("image/Loading/snow_loading/frame-000008.png").getImage(),
60, 80, 286, 50, this);
}else if (time <= 150) {
g.drawImage(
new ImageIcon("image/Loading/snow_loading/frame-000007.png").getImage(),
60, 80, 286, 50, this);
}else if (time <= 160) {
g.drawImage(
new ImageIcon("image/Loading/snow_loading/frame-000006.png").getImage(),
60, 80, 286, 50, this);
}else if (time <= 170) {
g.drawImage(
new ImageIcon("image/Loading/snow_loading/frame-000005.png").getImage(),
60, 80, 286, 50, this);
}else if (time <= 180) {
g.drawImage(
new ImageIcon("image/Loading/snow_loading/frame-000004.png").getImage(),
60, 80, 286, 50, this);
}else if (time <= 190) {
g.drawImage(
new ImageIcon("image/Loading/snow_loading/frame-000003.png").getImage(),
60, 80, 286, 50, this);
}else if (time <= 210) {
g.drawImage(
new ImageIcon("image/Loading/snow_loading/frame-000002.png").getImage(),
60, 80, 286, 50, this);
}
time++;
if (time >= 210) {
time = 1;
}
}
@Override
public void run() {
while (true) {
this.repaint();
try {
Thread.sleep(10);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
@Override
public void run() {
this.launchFrame();
}
}
reg?sid=25110http://yuncode.net/reg?sid=25110