请问怎么设定让一个JTextArea只能输入200个字节,谢谢 写事件,getText,转换成byte,判断是否超过200应该可以实现吧没用过DocumentListener 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用documentListener 监听JTextArea component 记录打击key的次数,来约束 import javax.swing.*;import javax.swing.event.*;import java.awt.*;public class TextArea { static int length=0; JTextArea ta; TextArea() { JFrame frame=new JFrame(); ta=new JTextArea(); frame.getContentPane().add(ta); ta.setLineWrap(true); ta.getDocument().addDocumentListener(new DocumentListener() { public void insertUpdate(DocumentEvent e) { if (length==200) ta.setEditable(false); length++; } public void removeUpdate(DocumentEvent e) { } public void changedUpdate(DocumentEvent e) { } }); frame.setSize(100,200); frame.setVisible(true); } public static void main(String[] args) { new TextArea(); }} JAVA怎么创建32位BMP的图片???? 在往分了区的表中添加记录时总是提示“这类索引的分区处于不可用状态” 关于环境变量 朋友帮帮忙,能解决问题者必给加分 变量命名问题 关于JAVA中straic java在认证服务器上如何应用?谢谢各位了 使用rmi是不是可以得到机器的诸如cpu,memory等信息? 前辈们,可以帮我一下吗?帮我看一下下面的代码,我有些地方不懂 又没有人推荐一下 初学javase应该看点什么书 几个基础的问题... 运算流程,
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
public class TextArea {
static int length=0;
JTextArea ta;
TextArea()
{
JFrame frame=new JFrame();
ta=new JTextArea();
frame.getContentPane().add(ta);
ta.setLineWrap(true);
ta.getDocument().addDocumentListener(new DocumentListener() {
public void insertUpdate(DocumentEvent e) {
if (length==200)
ta.setEditable(false);
length++;
} public void removeUpdate(DocumentEvent e) {
} public void changedUpdate(DocumentEvent e) {
}
}); frame.setSize(100,200);
frame.setVisible(true); }
public static void main(String[] args) {
new TextArea(); }
}