?? filecancelbutton.java~39~
字號:
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 fromPeople;
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.fromPeople = 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:");
}
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 + -