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

📄 facedialog.java

📁 用java开发的QQ管理系统
💻 JAVA
字号:
package com.zlf.qqclient.mainframe.facedialog;
/**
 * 表情框
 * @author zlf
 */
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridLayout;
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.io.File;

import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.JTextPane;

import com.zlf.qqclient.utils.QQUtils;

public class FaceDialog extends JDialog implements WindowListener {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private JPanel mainPane;

	private JTextPane sendText;
	/**
	 * 
	 * @param pSendText
	 * 
	 */
	public FaceDialog(JTextPane pSendText) {
		this.sendText = pSendText;
		mainPane = new JPanel();
		mainPane.setLayout(new GridLayout(6, 16, 2, 2));

		File f = new File(QQUtils.properties.getProperty("Face"));
		File[] fileList = f.listFiles();
		for (int i = 0; i < fileList.length; i++) {
			ImageIcon icon =(ImageIcon) QQUtils.getFaceIcon(fileList[i].getName());
			final JButton tmpBut = new JButton(icon);
			tmpBut.setActionCommand(fileList[i].getName());
			tmpBut.setToolTipText(fileList[i].getName());
			tmpBut.setBorder(BorderFactory.createEmptyBorder());
			tmpBut.setBackground(Color.WHITE);
			tmpBut.addMouseListener(new MouseListener() {

				public void mouseClicked(MouseEvent e) {

				}

				public void mouseEntered(MouseEvent e) {
					tmpBut.setBorder(BorderFactory.createLineBorder(Color.BLUE));

				}

				public void mouseExited(MouseEvent e) {
					tmpBut.setBorder(BorderFactory.createEmptyBorder());

				}

				public void mousePressed(MouseEvent e) {

				}

				public void mouseReleased(MouseEvent e) {

				}
			});
			// 點擊每個表情按鈕時,執行的代碼
			tmpBut.addActionListener(new ActionListener() {

				public void actionPerformed(ActionEvent e) {
					ImageIcon icon = (ImageIcon) QQUtils.getFaceIcon(e.getActionCommand());
					sendText.insertIcon(icon);
					FaceDialog.this.dispose();
				}

			});
			mainPane.add(tmpBut);
		}

		this.addWindowListener(this);
		// 禁用或启用此 dialog 的装饰。只有在 dialog 不可显示时才调用此方法。
		this.setUndecorated(true);
		this.setSize(new Dimension(340, 180));
		this.getContentPane().add(mainPane);
	}

	public void windowActivated(WindowEvent e) {
		// TODO Auto-generated method stub

	}

	public void windowClosed(WindowEvent e) {
		// TODO Auto-generated method stub

	}

	public void windowClosing(WindowEvent e) {
		// TODO Auto-generated method stub

	}

	// 当 Window 不再是活动 Window 时调用,釋放表情對話框
	public void windowDeactivated(WindowEvent e) {
		this.dispose();
	}

	public void windowDeiconified(WindowEvent e) {
		// TODO Auto-generated method stub

	}

	public void windowIconified(WindowEvent e) {
		// TODO Auto-generated method stub

	}

	public void windowOpened(WindowEvent e) {
		// TODO Auto-generated method stub

	}

}

⌨️ 快捷键说明

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