is there a append feature for JLabel, like in JTextArea?
JTextArea Text = new JTextArea("including; ");
Text.append("button1,");
否,但是每次您要添加文本时都可以执行以下操作
label.setText(label.getText() + "text u want to append");
If you really want a method called .append(text)
, you can create your own custom Label
public class MyLabel extends JLabel {
public MyLabel(String text) {
super(text);
}
public void append(String appendText) {
setText(getText() + appendText);
}
}
Than you can create your Label:
MyLabel myLabel = new MyLabel("First Text");
myLabel.append("Appended Text");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.