📄 filecancelbutton.java~41~
字号:
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;
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("您要向" + this.toPeople + "发送的文件[" + this.toSendFile.getName() +
"]正在等待对方连接...", JLabel.LEFT);
//fileInfo=new JLabel("sending file");
cancelSendButton = new JButton("取消");
buttonJPanel = new JPanel();
cancelSendButton.setVisible(false);
cancelSendButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
cancelSendButton.setBorder(null);
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{
ChatArea.out.writeUTF("CANCEL_SENDING:"+this.toPeople+"#FROMPEOPLE#"+this.userName+"TOSENDFILE"+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("您取消了对"+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 + -