📄 facedialog.java
字号:
package com.softfz.jn0708.chat.sendpanel;
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 java.io.File;
import java.net.URL;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import com.softfz.jn0708.chat.chatcontent.ChatContent;
import com.softfz.jn0708.images.Images;
/**
* 表情对话框
*/
public class FaceDialog extends JDialog implements WindowListener{
private static final long serialVersionUID = 1L;
private JPanel facePanel=new JPanel();
private int tmpCount = 0;
private ChatContent chatcontent = null;
private SendPanel sendpanel = null;
/**
* 表情对话框构造函数
* @param chatcontent 聊天内容面板
* @param sendpanel 发送按钮面板
*/
public FaceDialog(ChatContent chatcontent,final SendPanel sendpanel){
super();
this.setUndecorated(true);
this.chatcontent=chatcontent;
this.sendpanel = sendpanel;
facePanel.setLayout(new GridLayout(6,16,1,1));
facePanel.setPreferredSize(new Dimension(350,150));
//this.setMinimumSize(new Dimension(347,33));
facePanel.setMaximumSize(new Dimension(350,150));
// this.setSize(374,194);
File file=new File("./images/face/");
File[] fileList=file.listFiles();
// System.out.println(fileList.length);
for (int i=0;i<fileList.length;i++){
URL url = Images.class.getResource("face/"+fileList[i].getName());
ImageIcon icon = new ImageIcon(url);
final JButton tmpBtn=new JButton(icon);
tmpBtn.setActionCommand(fileList[i].getName());
tmpBtn.setToolTipText(fileList[i].getName());
tmpBtn.setBorder(BorderFactory.createEmptyBorder());
tmpBtn.setBackground(Color.WHITE);
facePanel.add(tmpBtn);
tmpBtn.addMouseListener(new MouseListener(){
public void mouseClicked(MouseEvent e) {
// TODO 自动生成方法存根
}
public void mouseEntered(MouseEvent e) {
tmpBtn.setBorder(BorderFactory.createLineBorder(Color.BLUE));
}
public void mouseExited(MouseEvent e) {
tmpBtn.setBorder(BorderFactory.createEmptyBorder());
}
public void mousePressed(MouseEvent e) {
// TODO 自动生成方法存根
}
public void mouseReleased(MouseEvent e) {
// TODO 自动生成方法存根
}
});
/**
* 表情按钮监听
*/
tmpBtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
URL url = Images.class.getResource("face/"+e.getActionCommand());
ImageIcon icon=new ImageIcon(url);
//System.out.println(url);
sendpanel.getJtpininfo().insertIcon(icon);
FaceDialog.this.dispose();
}
});
}
this.getContentPane().add(facePanel);
// this.setSize(340,180);
this.addWindowListener(this);
this.setVisible(true);
this.pack();
}
public void windowActivated(WindowEvent e) {
// TODO 自动生成方法存根
}
public void windowClosed(WindowEvent e) {
// TODO 自动生成方法存根
}
public void windowClosing(WindowEvent e) {
// TODO 自动生成方法存根
}
public void windowDeactivated(WindowEvent e) {
this.dispose();
}
public void windowDeiconified(WindowEvent e) {
// TODO 自动生成方法存根
}
public void windowIconified(WindowEvent e) {
// TODO 自动生成方法存根
}
public void windowOpened(WindowEvent e) {
// TODO 自动生成方法存根
}
/**
* 获取发送面板
* @return
*/
public SendPanel getSendpanel() {
return sendpanel;
}
// public void setSendpanel(SendPanel sendpanel) {
// this.sendpanel = sendpanel;
// }
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -