f.setLayout(new BorderLayout()); listenButton=new JButton("连接端口8600"); f.add(listenButton, BorderLayout.NORTH); sessionTextArea=new JTextArea(); f.add(sessionTextArea, BorderLayout.CENTER); jLabel=new JLabel("发送:"); sendTextField=new JTextField(20); sendButton=new JButton("发送消息"); pl=new JPanel(); pl.setLayout(new FlowLayout()); pl.add(jLabel); pl.add(sendTextField); pl.add(sendButton); f.add(pl, BorderLayout.SOUTH); setTitle("客户端"); setSize(500,300); setVisible(true); listenButton.addActionListener(this); sendButton.addActionListener(this);
jLabel=new JLabel("发送:");
sendTextField=new JTextField(20); sendButton=new JButton("发送消息"); pl=new JPanel(); pl.setLayout(new FlowLayout()); pl.add(jLabel); pl.add(sendTextField); pl.add(sendButton); f.add(pl, BorderLayout.SOUTH); setTitle("客户端"); setSize(500,300); setVisible(true); listenButton.addActionListener(this); sendButton.addActionListener(this);