Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Java SE 综合讨论区  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 帮忙改改 (线程)
xingchao





发贴: 32
积分: 0
于 2006-12-09 17:38 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
帮忙改改这个程序
我想从一个text中输入字符 然后从 另一个textArea 中输出 要用线程编写

import java.io.*;
import java.util.*;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

public class Ms extends JFrame implements ActionListener{

class Message1{
JTextField t1=new JTextField();
}
Message1 message1=new Message1();
JPanel p1=new JPanel();
JPanel p2=new JPanel();
JButton b1=new JButton("send");
JButton b2=new JButton("Close");
Container cp=getContentPane();
String message;
Ms(){
message1.t1.setEditable(false);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
p1.setLayout( new FlowLayout());
p1.add(b1,FlowLayout.LEFT);
p1.add(b2,FlowLayout.RIGHT);
p2.setLayout(new FlowLayout());
p2.add(message1.t1,FlowLayout.CENTER);
cp.setLayout(new BorderLayout(5,5));
cp.add(p1,BorderLayout.SOUTH);
cp.add(p2,BorderLayout.CENTER);
}
public void actionPerformed(ActionEvent e){
if(e.getSource()==b1){
message = message1.t1.getText();
MsThread mm = new MsThread();
mm.setMessgae(message);
mm.start();
}
}

class MsThread extends Thread{
Message2 message2=new Message2();
String m;
public void setMessgae(String ss){
m = ss;

}
public void run(){
message2.t2.setText()=m;
}
}

class Message2 extends JFrame {
JTextArea t2=new JTextArea(10,40);
Message2(){
setSize(300,200);
setTitle("talk");

addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
}
}
public void hh(){
Ms k=new Ms();
k.show();
}

public static void main(String args[]){
Ms m=new Ms();
m.hh();
}
}


Ms.java (1.5k)


why edited on 2006-12-10 10:44


吐个泡....

话题树型展开
人气 标题 作者 字数 发贴时间
6778 帮忙改改 (线程) xingchao 1766 2006-12-09 17:38
5104 Re:帮忙改改 (线程) myfend 2011 2006-12-10 11:03

flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923