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

📄 chatjframe.java

📁 多线程扫描IP段
💻 JAVA
字号:
/* * ChatJFrame.java * Created on 2008年6月20日, 上午9:02 *//** * @author  asdtiang */import java.net.*;public class ChatJFrame extends javax.swing.JFrame {        /** Creates new form ChatJFrame */    public ChatJFrame() {        initComponents();           }    public void title(String ip,String name){        rname=name;        this.setTitle("IP为:"+ip+"计算机名为:"+rname);        msg.setColumns(20);        msg.setLineWrap(true);        this.setSize(400, 200);        this.setVisible(true);      }        /** This method is called from within the constructor to     * initialize the form.     * WARNING: Do NOT modify this code. The content of this method is     * always regenerated by the Form Editor.     */    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents    private void initComponents() {        jButton1 = new javax.swing.JButton();        jScrollPane2 = new javax.swing.JScrollPane();        msg = new javax.swing.JTextArea();        jButton1.setText("Send");        jButton1.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                jButton1ActionPerformed(evt);            }        });        msg.setColumns(20);        msg.setRows(5);        jScrollPane2.setViewportView(msg);        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());        getContentPane().setLayout(layout);        layout.setHorizontalGroup(            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()                .addContainerGap()                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)                    .addComponent(jButton1)                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 354, Short.MAX_VALUE))                .addGap(36, 36, 36))        );        layout.setVerticalGroup(            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addGroup(layout.createSequentialGroup()                .addGap(21, 21, 21)                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE)                .addGap(18, 18, 18)                .addComponent(jButton1)                .addContainerGap(23, Short.MAX_VALUE))        );        pack();    }// </editor-fold>//GEN-END:initComponents    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed          try{              DatagramSocket socket=new DatagramSocket();              String info;              info=null;              info=msg.getText();              byte[] b;              b=info.getBytes();              DatagramPacket packet=new DatagramPacket(b,b.length);              InetAddress raddr= InetAddress.getByName(rname);              packet.setAddress(raddr);              packet.setPort(3000);              socket.send(packet);              ChatMainJFrame.msg.append("To: "+rname+"\n"+"     "+info+"\n");              msg.setText("");                             }          catch(Exception e){}// TODO add your handling code here:    }//GEN-LAST:event_jButton1ActionPerformed    /**     * @param args the command line arguments     */       // Variables declaration - do not modify//GEN-BEGIN:variables    private javax.swing.JButton jButton1;    private javax.swing.JScrollPane jScrollPane2;    private javax.swing.JTextArea msg;    // End of variables declaration//GEN-END:variables    public String rname=null;}

⌨️ 快捷键说明

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