提交 07d4547a 编写于 作者: weixin_50772964's avatar weixin_50772964

Update UI.java

上级 6c48b0a8
package ftp;
import org.apache.commons.net.ftp.FTPClient;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
......@@ -31,6 +29,7 @@ public class UI extends JFrame {
JScrollPane jScrollPane = new JScrollPane();
TaskList t=new TaskList();
listPanel listpanel = new listPanel(t);
public UI (){
setTitle("ftp软件");
......@@ -38,7 +37,7 @@ public class UI extends JFrame {
setLayout(null);
setBounds(0,0,1200,900);
setBounds(0,0,1200,870);
jTextArea.setEditable(false);
jScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
jScrollPane.setViewportView(jTextArea);
......@@ -65,13 +64,14 @@ public class UI extends JFrame {
jPasswordField.setBounds(610,20,130,20);
jButton1.setBounds(750,20,60,20);
jButton2.setBounds(820,20,100,20);
jButton3.setBounds(170,290,90,40);
jButton4.setBounds(750,290,90,40);
localpanel.setBounds(30,330,450,300);
ftpPanel.setBounds(500,330,450,300);
jButton5.setBounds(650,290,90,40);
jButton6.setBounds(850,290,90,40);
jButton3.setBounds(170,270,90,40);
jButton4.setBounds(750,270,90,40);
localpanel.setBounds(30,310,450,250);
ftpPanel.setBounds(500,310,450,250);
jButton5.setBounds(650,270,90,40);
jButton6.setBounds(850,270,90,40);
jScrollPane.setBounds(30,50,800,200);
listpanel.setBounds(30,560,800,210);
......@@ -92,6 +92,7 @@ public class UI extends JFrame {
c.add(jButton6);
c.add(localpanel);
c.add(ftpPanel);
c.add(listpanel);
//c.add(jTextArea);
c.add(jScrollPane);
......@@ -102,12 +103,32 @@ public class UI extends JFrame {
}
/*@Override
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand() == "连接") {
if(jTextField1.getText()==null||jTextField2.getText()==""||jTextField3.getText()==""||jPasswordField.getText()==""){
JOptionPane .showMessageDialog(null,"输入不能为空","",JOptionPane.PLAIN_MESSAGE);
}
else{
//建立连接的代码
}
} else if (e.getActionCommand() == "断开连接") {//如果事件源是 jbClear,那么清除文本框的文字
//断开连接的代码
}
}*/
class jButton1event implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
String password=new String(jPasswordField.getPassword());
if(jTextField1.getText().trim().equals("")||jTextField2.getText().trim().equals("")||jTextField3.getText().trim().equals("")||password.trim().equals("")){
/*if(jTextField1.getText().trim().equals("")||jTextField2.getText().trim().equals("")||jTextField3.getText().trim().equals("")||password.trim().equals("")){
JOptionPane.showMessageDialog(null,"输入不能为空","",JOptionPane.PLAIN_MESSAGE);
......@@ -117,7 +138,7 @@ public class UI extends JFrame {
if(jTextField1.getText().trim().equals("43.139.43.93")){
if(jTextField2.getText().trim().equals("21")){
if(jTextField3.getText().trim().equals("1")){
if(password.trim().equals("Qaz112") ){
if(password.trim().equals("Qaz112")){
FTPClient ftpClient=ftp.Connect.connectFtpServer("43.139.43.93",21,"1","Qaz112","GBK");
Global.setFTPClient(ftpClient);
if(ftpClient.isConnected()){
......@@ -146,6 +167,17 @@ public class UI extends JFrame {
jTextArea.append("\n");
number++;
}
}*/
if(ftp.Connect.isConnected(ftpClient)){
jTextArea.append(number+".连接成功");
ftpPanel.initx();
jTextArea.append("\n");
number++;
}else{
jTextArea.append(number+".连接失败");
ftpPanel.initx();
jTextArea.append("\n");
number++;
}
}
}
......@@ -197,20 +229,13 @@ public class UI extends JFrame {
@Override
public void actionPerformed(ActionEvent e) {
if(localpanel.getindex()==-1){
jTextArea.append(number+".请选择文件");
jTextArea.append("\n");
number++;
}
else{String filepath = new String();
filepath = localpanel.getCurrentPath()+"\\"+localpanel.getfile1();
System.out.println(filepath);
t.newDownload(ftpPanel.getfile1(),localpanel.getCurrentPath(),ftpClient);
listpanel.refresh();
//文件路径为filepath,剩下的代码为下载操作。
jTextArea.append(number+".下载成功");
jTextArea.append("\n");
number++;
}
}
}
......@@ -229,6 +254,7 @@ public class UI extends JFrame {
System.out.println(filepath);
t.newUpload(ftpClient,filepath);
//文件路径为filepath,剩下的代码为上传操作。
listpanel.refresh();
jTextArea.append(number+".");
jTextArea.append("\n");
number++;
......@@ -243,3 +269,4 @@ public class UI extends JFrame {
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册