📄 filecancelbutton.java~15~
字号:
package chat;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.JPanel;
import javax.swing.*;
import java.util.*;
public class FileCancelButton extends JPanel implements ActionListener{
//BorderLayout borderLayout1 = new BorderLayout();
String toPeople;
File toSendFile;
String userName;
String key;
String cancelButtonText="<html><u><font size=5 style=font-family:宋体,background:#8CADD7>取消</font></u></html>";
JLabel fileInfo;
JButton cancelSendButton;
JPanel buttonJPanel;
static Hashtable saveFileCancel=new Hashtable();
public FileCancelButton(String toPeople,File toSendFile) {
this.toPeople = toPeople;
this.toSendFile = toSendFile;
key = this.toPeople + this.toSendFile;
this.userName = ChatArea.loginDialog.getName();
saveFileCancel.put(key, this);
//System.out.println(this.toPeople + " " + this.toSendFile);
fileInfo = new JLabel(Constant.getLang("GG_nyx") + this.toPeople + Constant.getLang("GG_fsdwj") + this.toSendFile.getName() +
Constant.getLang("GG_zzdddflj"), JLabel.LEFT);
//fileInfo=new JLabel("sending file");
cancelSendButton = new JButton(cancelButtonText);
buttonJPanel = new JPanel();
//cancelSendButton.setVisible(false);
cancelSendButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
cancelSendButton.setBorder(null);
cancelSendButton.setContentAreaFilled(false);
fileInfo.setBackground(new Color(140,173,215));
cancelSendButton.setBackground(new Color(140,173,215));
buttonJPanel.setBackground(new Color(140,173,215));
this.setBackground(new Color(140,173,215));
fileInfo.setForeground(Color.white);
fileInfo.setFont(new Font("Dialog", 0, 16));
//cancelSendButton.setFont(new Font("Dialog",Font.ITALIC+Font.BOLD,16));
//fileInfo=new JLabel();
cancelSendButton.addActionListener(this);
buttonJPanel.add(cancelSendButton);
this.add(fileInfo, BorderLayout.WEST);
this.add(buttonJPanel, BorderLayout.CENTER);
}
public void actionPerformed(ActionEvent e){
if(e.getSource()==cancelSendButton){
this.buttonJPanel.setVisible(false);
try{
this.fileInfo.setText(Constant.getLang("GG_nqxld")+this.toPeople+Constant.getLang("GG_wj")+this.toSendFile.getName()+Constant.getLang("GG_dfs"));
ChatArea.out.writeUTF("CANCEL_SENDING:"+this.toPeople+"#TOPEOPLE#"+this.userName+"#FILENAME#"+this.toSendFile);
}catch(Exception e1){
}
ClientSendFileThread cancelFileThread = (ClientSendFileThread)
ClientSendFileThread.saveThread.get(key);
try {
//System.out.println("发送文件exception");
cancelFileThread.dos.flush();
cancelFileThread.dos.close();
cancelFileThread.dis.close();
cancelFileThread.raf.close();
cancelFileThread.socket.close();
this.fileInfo.setText(Constant.getLang("GG_nqxld")+this.toPeople+"文件["+this.toSendFile.getName()+"]的发送");
ClientSendFileThread.saveThread.remove(cancelFileThread);
//FileCancelButton.saveFileCancel.remove(this);
}
catch (Exception ex) {
}
}
}
void jbInit() throws Exception {
// this.setLayout(borderLayout1);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -