public void caretUpdate(CaretEvent e) {
if(e.getSource()==tname){
if(tname.getText().length()>6){
sname=tname.getText();
tname.setText(sname.substring(0, 5));//当文本长度大于6时 运行到此处时为什么有异常?
}
}
if(e.getSource()==tphone){
if(tphone.getText().length()>14){
tphone.setText(tphone.getText().substring(0,14));
}
}
if(e.getSource()==tqq){
if(tqq.getText().length()>10){
tqq.setText(tqq.getText().substring(0, 10));
}
}
if(e.getSource()==temall){
if(temall.getText().length()>20){
temall.setText(temall.getText().substring(0, 20));
}
}
if(e.getSource()==taddress){
if(taddress.getText().length()>20){
taddress.setText(taddress.getText().substring(0, 20));
}
}
if(e.getSource()==tremark){
if(tremark.getText().length()>100){
tremark.setText(temall.getText().substring(0, 100));
}
}
------解决方案--------------------------------------------------------
数组下标越界?
tname.setText(sname.substring(0, 5));//当文本长度大于6时 运行到此处时为什么有异常?
0,1,2,3,4,5正好六个长度,超过6的话,因为超出长度,报错了?
报的什么错误?