用TextArea显示多行数据,代码如下所示,请问为什么会在第二行中出现一个空白部分,截图中第2行中的白色部分。以为是宽度问题,可是调整宽度之后,仍然有这个空格,请问,为什么,怎么解决?
setText中的字符串没有换行。
package Test;
import java.awt.*;
import java.applet.Applet;
public class TextAreaT extends Applet{
public void init(){
super.setLayout(new BorderLayout(0,0));
setLayout(null);
setSize(400,400);
TextArea ta=new TextArea("",0,0,TextArea.SCROLLBARS_VERTICAL_ONLY);
ta.setText("現 72,670(17*) 有 69,420(18*) 無 69,420(18*) 差 0");
ta.setBounds(10,20,240,66);
add(ta);
ta.setVisible(true);
setVisible(true);
}
public void start(){
}
public void stop(){
}
}
setText中的字符串没有换行。
package Test;
import java.awt.*;
import java.applet.Applet;
public class TextAreaT extends Applet{
public void init(){
super.setLayout(new BorderLayout(0,0));
setLayout(null);
setSize(400,400);
TextArea ta=new TextArea("",0,0,TextArea.SCROLLBARS_VERTICAL_ONLY);
ta.setText("現 72,670(17*) 有 69,420(18*) 無 69,420(18*) 差 0");
ta.setBounds(10,20,240,66);
add(ta);
ta.setVisible(true);
setVisible(true);
}
public void start(){
}
public void stop(){
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货