/*
* P2p_ui.java
*
* Created on __DATE__, __TIME__
*/
package flying.ui;
import java.util.Vector;
import javax.swing.DefaultListModel;
import javax.swing.JList;
import javax.swing.JScrollPane;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import response.InfoQueue;
import response.InfoResponse;
import flying.do_xml.XmlFormat;
import flying.getlocalip.GetLocalip;
import flying.receive.ReceiveMutiCast;
import flying.receive.ReceiveP2p;
import flying.sender.Sender;
/**
*
* @author __USER__
*/
public class P2p_ui extends javax.swing.JFrame {
/** Creates new form P2p_ui */
Vector ipItem = new Vector(10, 10);//ip集
Vector messageItem = new Vector(); //消息集
public DefaultListModel modeIp = new DefaultListModel(); //implements the java.util.Vector API
public DefaultListModel modeMessage = new DefaultListModel();
GetLocalip getLocalip = new GetLocalip();
XmlFormat xmlFormat = new XmlFormat();
Sender sender = new Sender(P2p_ui.this);
ReceiveMutiCast receiveMutiCast = new ReceiveMutiCast(P2p_ui.this);
ReceiveP2p receiveP2p = new ReceiveP2p(P2p_ui.this);
public InfoQueue infoQueue = new InfoQueue();
InfoResponse infoResponse = new InfoResponse(P2p_ui.this);
public P2p_ui() { //构造方法
setTitle("P2P chat ---by flying");
initComponents();
receiveMutiCast.start();
receiveP2p.start();
infoResponse.start();
}
/** 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.
*/
//GEN-BEGIN:initComponents
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
jLabel2 = new javax.swing.JLabel();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jTextField1 = new javax.swing.JTextField();
jTextField2 = new javax.swing.JTextField();
jScrollPane1 = new javax.swing.JScrollPane();
jList1 = new javax.swing.JList();
jScrollPane2 = new javax.swing.JScrollPane();
jList2 = new javax.swing.JList();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setText("在线主机");
jButton1.setText("获取ip列表");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jLabel2.setText(" 消息记录框");
jButton2.setText("发送");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
jButton3.setText("关闭");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
jLabel3.setText("目的ip");
jLabel4.setText(" 消息");
jTextField1.setText("");
jTextField2.setText("");
jList1=new JList(modeIp);
ListSelectionListener listSelectionListener = new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
jTextField1.setText(jList1.getSelectedValue() .toString() );
}
};
jList1.addListSelectionListener(listSelectionListener) ;
jList2=new JList(modeMessage);
jScrollPane1.setViewportView(jList1);
jScrollPane2.setViewportView(jList2);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(
getContentPane());
getContentPane().setLayout(layout);
layout
.setHorizontalGroup(layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(
layout
.createSequentialGroup()
.addContainerGap()
.addGroup(
layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(
layout
.createSequentialGroup()
.addGap(
19,
19,
19)
.addComponent(
jLabel1,
javax.swing.GroupLayout.PREFERRED_SIZE,
76,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(
layout
.createSequentialGroup()
.addGroup(
layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(
layout
.createSequentialGroup()
.addGap(
10,
10,
10)
.addComponent(
jLabel3,
javax.swing.GroupLayout.PREFERRED_SIZE,
50,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(
jLabel4,
javax.swing.GroupLayout.PREFERRED_SIZE,
83,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(
jButton2,
javax.swing.GroupLayout.PREFERRED_SIZE,
85,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(
10,
10,
10)
.addGroup(
layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(
jTextField1,
javax.swing.GroupLayout.PREFERRED_SIZE,
159,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(
layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(
jButton3,
javax.swing.GroupLayout.PREFERRED_SIZE,
78,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(
jTextField2,
javax.swing.GroupLayout.PREFERRED_SIZE,
213,
javax.swing.GroupLayout.PREFERRED_SIZE))))
.addComponent(
jScrollPane2,
javax.swing.GroupLayout.DEFAULT_SIZE,
333,
Short.MAX_VALUE)
.addGroup(
layout
.createSequentialGroup()
.addGap(
10,
10,
10)
.addGroup(
layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(
layout
.createSequentialGroup()
.addComponent(
jScrollPane1,
javax.swing.GroupLayout.PREFERRED_SIZE,
187,
javax.swing.GroupLayout.PREFERRED_S
- 1
- 2
前往页