TextField与TextArea
在TextField中输入内容按回车显示在TextArea中,可是我按回车显示不了,这是怎么回事啊?求大家指教!!
import java.awt.*;
import java.awt.event.*;
public class ChatClient extends Frame {
TextField tfTxt = new TextField();
TextArea taContent = new TextArea();
public static void main(String[] args) {
new ChatClient().launchFrame();
}
public void launchFrame() {
setLocation(400,300);
this.setSize(300,300);
add(tfTxt,BorderLayout.SOUTH);
add(taContent,BorderLayout.NORTH);
pack();
this.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
tfTxt.addActionListener(new TFListener());
setVisible(true);
}
private class TFListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
String str = tfTxt.getText().trim();
taContent.setText(str );
taContent.setText("");
}
}
}
import java.awt.*;
import java.awt.event.*;
public class ChatClient extends Frame {
TextField tfTxt = new TextField();
TextArea taContent = new TextArea();
public static void main(String[] args) {
new ChatClient().launchFrame();
}
public void launchFrame() {
setLocation(400,300);
this.setSize(300,300);
add(tfTxt,BorderLayout.SOUTH);
add(taContent,BorderLayout.NORTH);
pack();
this.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
tfTxt.addActionListener(new TFListener());
setVisible(true);
}
private class TFListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
String str = tfTxt.getText().trim();
taContent.setText(str );
taContent.setText("");
}
}
}
...全文
相关推荐
[转]TextArea TextField 文本 即时显示最后一行
NULL 博文链接:https://as3.iteye.com/blog/910354
Draw2D 模拟SWT控件之TextField、TextArea
NULL 博文链接:https://salever.iteye.com/blog/719930
LWUIT 开发指南第二章里的 Hello TabbedPane、Hello TextArea、Hello TextField、Hello Calendar、Hello Tickering 源代码
其中包含五个项目,是博客《解读 LWUIT 之五:LWUIT 控件(下)》中作者写的 Hello TabbedPane、Hello TextArea、Hello TextField、Hello Calendar、Hello Tickering 源代码。博客链接地址:http://blog.csdn.net/defonds/archive/2010/02/23/5319480.aspx。
文本编辑器-textField实现
支持换行 空格 加粗 颜色 字号 字体 源码放送 用TextField实现
flex3 textArea 高度自适应
自已写了一个可根据内容 自动调整高度的TEXTAREA ,


Java SE
