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

📄 jdialogconnection.java~21~

📁 远程登录程序
💻 JAVA~21~
字号:
package multiclientnew;

import java.awt.BorderLayout;

import javax.swing.JFrame;
import javax.swing.JButton;
import javax.swing.JLabel;
import java.awt.Rectangle;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.*;
import java.io.*;
/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2007</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class JDialogConnection extends JFrame {
    PrintStream prsm;
    String nameRequest;
    String ipRequest;
    String thisName;
    DatagramSocket socket;
    byte[] buf =new byte[1000];
    DatagramPacket dp = new DatagramPacket(buf,buf.length);
    InetAddress serverHost;
    int serverPort =5566;
    public JDialogConnection(String thisname,String name,String ip,PrintStream cout) {
        thisName = thisname;
        nameRequest = name;
        ipRequest = ip;
        prsm = cout;
        try {
            jbInit();
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }

    private void jbInit() throws Exception {
        getContentPane().setLayout(null);
        this.setLocation(300,200);
        this.setSize(200,150);
        jLabel1.setText(nameRequest+"@ "+ipRequest+" "+"请求私聊");
        jLabel1.setBounds(new Rectangle(20, 10, 224, 35));
        this.setTitle("DialogConnection");
        this.setVisible(true);
        jButton2.setBounds(new Rectangle(96, 62, 87, 28));
        jButton2.setText("拒绝 ");
        jButton2.addActionListener(new JDialogConnection_jButton2_actionAdapter(this));
        jButton1.addActionListener(new JDialogConnection_jButton1_actionAdapter(this));
        this.getContentPane().add(jLabel1);
        this.getContentPane().add(jButton1);
        this.getContentPane().add(jButton2);
        jButton1.setBounds(new Rectangle(7, 62, 77, 28));
        jButton1.setText("同意");
    }
    JLabel jLabel1 = new JLabel();
    JButton jButton1 = new JButton();
    JButton jButton2 = new JButton();
    public void jButton1_actionPerformed(ActionEvent e) {
       String str;
       str ="Connection:同意";
       prsm.println(str);
       this.setVisible(false);
    }

    public void jButton2_actionPerformed(ActionEvent e) {
          String str;
          str = "Connection:拒绝";
          prsm.println(str);
          this.setVisible(false);
    }
}


class JDialogConnection_jButton2_actionAdapter implements ActionListener {
    private JDialogConnection adaptee;
    JDialogConnection_jButton2_actionAdapter(JDialogConnection adaptee) {
        this.adaptee = adaptee;
    }

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


class JDialogConnection_jButton1_actionAdapter implements ActionListener {
    private JDialogConnection adaptee;
    JDialogConnection_jButton1_actionAdapter(JDialogConnection adaptee) {
        this.adaptee = adaptee;
    }

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

⌨️ 快捷键说明

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