⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 zipclientframe.java

📁 java网络编程 包含全书所有代码编程以及实例
💻 JAVA
字号:
package zipsocket;import java.awt.*;import java.awt.event.*;import javax.swing.*;import java.net.*;import java.io.*;import java.util.zip.*;public class zipClientFrame extends JFrame {  private JPanel contentPane;  private Button button1 = new Button();  private Label label1 = new Label();  //Construct the frame  public zipClientFrame() {    enableEvents(AWTEvent.WINDOW_EVENT_MASK);    try {      jbInit();    }    catch(Exception e) {      e.printStackTrace();    }  }  //Component initialization  private void jbInit() throws Exception  {    //setIconImage(Toolkit.getDefaultToolkit().createImage(zipClientFrame.class.getResource("[Your Icon]")));    contentPane = (JPanel) this.getContentPane();    button1.setLabel("接收数据");    button1.setBounds(new Rectangle(109, 185, 92, 32));    button1.addActionListener(new java.awt.event.ActionListener() {      public void actionPerformed(ActionEvent e) {        button1_actionPerformed(e);      }    });    contentPane.setLayout(null);    this.setSize(new Dimension(304, 265));    this.setTitle("Zip网络数据流客户端");    label1.setBounds(new Rectangle(90, 101, 158, 30));    contentPane.add(button1, null);    contentPane.add(label1, null);  }  //Overridden so we can exit when window is closed  protected void processWindowEvent(WindowEvent e) {    super.processWindowEvent(e);    if (e.getID() == WindowEvent.WINDOW_CLOSING) {      System.exit(0);    }  }  void button1_actionPerformed(ActionEvent e) {    try    {      label1.setText("正在连接Zip网络数据流主机...");      Socket soc = new Socket("127.0.0.1", 5000);      DataInputStream tmpIn = new DataInputStream(soc.getInputStream());      ZipInputStream input = new ZipInputStream(tmpIn);      input.getNextEntry();      DataInputStream in = new DataInputStream(input);      String tmp = in.readUTF();      label1.setText(tmp);    }    catch(Exception e1)    {      System.out.println("Error:" + e1);    }  }}

⌨️ 快捷键说明

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