java题:就是点击发送按钮就把信息从单行文本框发送到多行文本框,然后再清除单行文本框的信息,求帮助!

[复制链接]
查看11 | 回复1 | 2011-5-21 11:48:57 | 显示全部楼层 |阅读模式
importjava.awt.*;
importjava.awt.event.*;
publicclassying
{
publicstaticvoidmain(String[]args)
{
Framef=newFrame(\"QQ\");
f.setLayout(null);
f.setSize(600,600);

TextAreata=newTextArea(\"\");
ta.setBounds(50,50,350,200);

TextFieldtf=newTextField(\"\");
tf.setBounds(50,300,350,50);

Buttonb1=newButton(\"发送\");
b1.setBounds(400,300,50,50);

Buttonb2=newButton(\"关闭\");
b2.setBounds(460,300,50,50);

shuyi=newshu();
b1.addActionListener(yi);

jieer=newjie();
b2.addActionListener(er);

f.add(ta);
f.add(tf);
f.add(b1);
f.add(b2);
f.setVisible(true);
}
}

classshuimplementsActionListener
{
publicvoidactionPerformed(ActionEvente)
{
ta.append(tf.setText()\"\");
tf.setText(\"\");
}
}
classjieimplementsActionListener
{
publicvoidactionPerformed(ActionEvente)
{System.exit(1);}
}
回复

使用道具 举报

千问 | 2011-5-21 11:48:57 | 显示全部楼层
importjava.awt.Button;
importjava.awt.Frame;
importjava.awt.TextArea;
importjava.awt.TextField;
importjava.awt.event.ActionEvent;
importjava.awt.event.ActionListener;
importjava.awt.event.WindowAdapter;
importjava.awt.event.WindowEvent;

publicclassyingextendsFrame{
//定义在外面
        TextAreata;
        TextFieldtf;

        publicying(){//用构造函数初始化
                ta=newTextArea(\"\");
                ta.setBounds(50,50,350,200);

                tf=newTextField(\"\");
                tf.setBounds(50,300,350,50);

                Buttonb1=newButton(\"发送\");
                b1.setBounds(400,300,50,50);

                Buttonb2=newButton(\"关闭\");
                b2.setBounds(460,300,50,50);

                add(ta);
                add(tf);
                add(b1);
                add(b2);


                //shuyi=newshu();
                b1.addActionListener(newActionListener(){

                        @Override
                        publicvoidactionPerformed(ActionEvente){
                                //TODOAuto-generatedmethodstub
                                ta.append(tf.getText()\"\\n\");
                                tf.setText(\"\");
                        }
                });

                jieer=newjie();
                b2.addActionListener(er);
               
               
                addWindowListener(newWindowAdapter(){
                        publicvoidwindowClosing(WindowEventee){
                                System.exit(0);
                        }
                });
        }

        publicstaticvoidmain(String[]args){
//                Framef=newFrame(\"QQ\");
                yingf=newying();
                f.setLayout(null);
                f.setTitle(\"QQ\");
                f.setSize(600,600);
                f.setVisible(true);
        }

        classjieimplementsActionListener{
                publicvoidactionPerformed(ActionEvente){
                        System.exit(0);//不是1
                }

        }
}




你的重新布局一下









<h4class=\"ask\">追问


能把你的qq给我吗,给你追分,你真是高手啊!!我的是471530693,
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行