mainframe.java

来自「java网络高级编程的配套源码,java网络高级编程为清华出版社出版.」· Java 代码 · 共 275 行

JAVA
275
字号
/*源程序清单12-16*/

package ftp;

import java.awt.*;
import java.awt.event.*;
import borland.jbcl.layout.*;
import borland.jbcl.control.*;
import borland.jbcl.model.*;
import sun.net.ftp.*;
import java.util.*;
import java.io.*;
import java.net.*;

public class MainFrame extends DecoratedFrame
{
  TextField textField1 = new TextField();
  Button button1 = new Button();
  TextField textField2 = new TextField();
  Label label2 = new Label();
  TextField textField3 = new TextField();
  Label label3 = new Label();
  TextField textField4 = new TextField();
  Button button2 = new Button();
  GroupBox groupBox1 = new GroupBox();
  GridControl gridControl1 = new GridControl();
  Button button3 = new Button();
  Button button4 = new Button();
  Button button5 = new Button();
  Button button6 = new Button();
  PaneLayout paneLayout1 = new PaneLayout();
  Panel panel1 = new Panel();
  PaneLayout paneLayout2 = new PaneLayout();
  Label label1 = new Label();
  GroupBox groupBox2 = new GroupBox();
  GroupBox groupBox3 = new GroupBox();
  PaneLayout paneLayout3 = new PaneLayout();
  TextArea textArea1 = new TextArea();
  PaneLayout paneLayout4 = new PaneLayout();
  PaneLayout paneLayout5 = new PaneLayout();
  List list1 = new List();
  Filer filer1 = new Filer(this,"文件下载到...",Filer.SAVE);
  Filer filer2 = new Filer(this,"上载文件...",Filer.LOAD);

  public MainFrame()
  {
    try
    {
      jbInit();
    }
    catch (Exception e)
    {
      e.printStackTrace();
    }
  }

  private void jbInit() throws Exception
  {
    this.setTitle("FTP上下载实例");
    button1.setLabel("连接");
    button1.addActionListener(new MainFrame_button1_actionAdapter(this));
    label2.setText("密码:");
    label3.setText("当前目录:");
    textField4.setEditable(false);
    button2.setLabel("上一级目录");
    button2.addActionListener(new MainFrame_button2_actionAdapter(this));
    groupBox1.setLayout(paneLayout1);
    groupBox1.setLabel("文件");
    button3.setLabel("下载");
    button3.addActionListener(new MainFrame_button3_actionAdapter(this));
    button4.setLabel("上载");
    button4.addActionListener(new MainFrame_button4_actionAdapter(this));
    button5.setLabel("断开");
    button5.addActionListener(new MainFrame_button5_actionAdapter(this));
    button6.setLabel("关闭");
    button6.addActionListener(new MainFrame_button6_actionAdapter(this));
    label1.setText("用户名:");
    groupBox2.setLayout(paneLayout5);
    groupBox2.setLabel("上下载队列");
    groupBox3.setLayout(paneLayout4);
    groupBox3.setLabel("上下载信息");
    panel1.setLayout(paneLayout3);
    this.setLayout(paneLayout2);
    gridControl1.setColumnCaptions(new String[] {"目录/文件", "大小", "日期"});
    gridControl1.addSubfocusListener(new MainFrame_gridControl1_subfocusAdapter(this));    
    groupBox1.add(button3, new PaneConstraints("button3", "button3", PaneConstraints.ROOT, 0.5f));
    groupBox1.add(gridControl1, new PaneConstraints("gridControl1", "button3", PaneConstraints.TOP, 0.8208955f));
    groupBox1.add(button4, new PaneConstraints("button4", "button3", PaneConstraints.RIGHT, 0.76666665f));
    groupBox1.add(button5, new PaneConstraints("button5", "button4", PaneConstraints.RIGHT, 0.6847826f));
    groupBox1.add(button6, new PaneConstraints("button6", "button5", PaneConstraints.RIGHT, 0.4948454f));
    this.add(groupBox1, new PaneConstraints("groupBox1", "groupBox1", PaneConstraints.ROOT, 0.5f));
    this.add(label3, new PaneConstraints("label3", "groupBox1", PaneConstraints.TOP, 0.1541096f));
    this.add(panel1, new PaneConstraints("panel1", "groupBox1", PaneConstraints.BOTTOM, 0.34661353f));
    panel1.add(groupBox2, new PaneConstraints("groupBox2", "groupBox2", PaneConstraints.ROOT, 0.5f));
    groupBox2.add(list1, new PaneConstraints("list1", "list1", PaneConstraints.ROOT, 1.0f));
    panel1.add(groupBox3, new PaneConstraints("groupBox3", "groupBox2", PaneConstraints.RIGHT, 0.50344825f));
    groupBox3.add(textArea1, new PaneConstraints("textArea1", "textArea1", PaneConstraints.ROOT, 1.0f));
    this.add(button1, new PaneConstraints("button1", "label3", PaneConstraints.TOP, 0.4666667f));
    this.add(button2, new PaneConstraints("button2", "label3", PaneConstraints.RIGHT, 0.4306569f));
    this.add(textField4, new PaneConstraints("textField4", "label3", PaneConstraints.RIGHT, 0.6680162f));
    this.add(textField2, new PaneConstraints("textField2", "button1", PaneConstraints.RIGHT, 0.80459774f));
    this.add(textField1, new PaneConstraints("textField1", "textField2", PaneConstraints.LEFT, 0.39999998f));
    this.add(label2, new PaneConstraints("label2", "textField2", PaneConstraints.RIGHT, 0.5165877f));
    this.add(textField3, new PaneConstraints("textField3", "label2", PaneConstraints.RIGHT, 0.6513761f));
    this.add(label1, new PaneConstraints("label1", "textField1", PaneConstraints.RIGHT, 0.2877698f));
    textField1.setText("10.15.43.216");
    gridControl1.setReadOnly(true);
    gridControl1.addMouseListener(new MainFrame_gridControl1_mouseAdapter(this));
    textArea1.setEditable(false);
  }

  public static void main(String[] args)
  {
    MainFrame frame=new MainFrame();
    frame.setLocation(100,100);
    frame.setSize(500,400);
    frame.show();
  }

  void button1_actionPerformed(ActionEvent e)
  {
  }

  void button3_actionPerformed(ActionEvent e)
  {
  }

  void button4_actionPerformed(ActionEvent e)
  {
  }
  
  void button5_actionPerformed(ActionEvent e)
  {
  }

  void button6_actionPerformed(ActionEvent e)
  {
  }

  void gridControl1_subfocusChanged(MatrixSubfocusEvent e)
  {
  }

  void gridControl1_mouseClicked(MouseEvent e)
  {
  }

  void button2_actionPerformed(ActionEvent e) {
  }

  }

}

class MainFrame_button1_actionAdapter implements java.awt.event.ActionListener
{
  MainFrame adaptee;

  MainFrame_button1_actionAdapter(MainFrame adaptee)
  {
    this.adaptee = adaptee;
  }

  public void actionPerformed(ActionEvent e)
  {
    adaptee.button1_actionPerformed(e);
  }
}

class MainFrame_button3_actionAdapter implements java.awt.event.ActionListener
{
  MainFrame adaptee;

  MainFrame_button3_actionAdapter(MainFrame adaptee)
  {
    this.adaptee = adaptee;
  }

  public void actionPerformed(ActionEvent e)
  {
    adaptee.button3_actionPerformed(e);
  }
}

class MainFrame_button4_actionAdapter implements java.awt.event.ActionListener
{
  MainFrame adaptee;

  MainFrame_button4_actionAdapter(MainFrame adaptee)
  {
    this.adaptee = adaptee;
  }

  public void actionPerformed(ActionEvent e)
  {
    adaptee.button4_actionPerformed(e);
  }
}

class MainFrame_button5_actionAdapter implements java.awt.event.ActionListener
{
  MainFrame adaptee;

  MainFrame_button5_actionAdapter(MainFrame adaptee)
  {
    this.adaptee = adaptee;
  }

  public void actionPerformed(ActionEvent e)
  {
    adaptee.button5_actionPerformed(e);
  }
}

class MainFrame_button6_actionAdapter implements java.awt.event.ActionListener
{
  MainFrame adaptee;

  MainFrame_button6_actionAdapter(MainFrame adaptee)
  {
    this.adaptee = adaptee;
  }

  public void actionPerformed(ActionEvent e)
  {
    adaptee.button6_actionPerformed(e);
  }
}

class MainFrame_gridControl1_subfocusAdapter extends borland.jbcl.model.MatrixSubfocusAdapter
{
  MainFrame adaptee;

  MainFrame_gridControl1_subfocusAdapter(MainFrame adaptee)
  {
    this.adaptee = adaptee;
  }

  public void subfocusChanged(MatrixSubfocusEvent e)
  {
    adaptee.gridControl1_subfocusChanged(e);
  }
}

class MainFrame_gridControl1_mouseAdapter extends java.awt.event.MouseAdapter
{
  MainFrame adaptee;

  MainFrame_gridControl1_mouseAdapter(MainFrame adaptee)
  {
    this.adaptee = adaptee;
  }

  public void mouseClicked(MouseEvent e)
  {
    adaptee.gridControl1_mouseClicked(e);
  }
}

class MainFrame_button2_actionAdapter implements java.awt.event.ActionListener
{
  MainFrame adaptee;

  MainFrame_button2_actionAdapter(MainFrame adaptee)
  {
    this.adaptee = adaptee;
  }

  public void actionPerformed(ActionEvent e)
  {
    adaptee.button2_actionPerformed(e);
  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?