how to repaint label components immediately?

zxgcharles 2000-03-03 01:42:00
in applet (IE Browser)
i want to repaint a label component immediately to reflect some state change. but it's delay.what can i do
thanks!
...全文
103 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
ahfei 2000-03-03
  • 打赏
  • 举报
回复
我试了下,没有什么问题,代码如下.每按一下button,label上的数字就加1

import java.awt.*;
import java.awt.event.*;
import java.applet.*;

public class Applet1 extends Applet {
boolean isStandalone = false;
Label label1 = new Label();
Button button1 = new Button();
int Count=0;

//Get a parameter value
public String getParameter(String key, String def) {
return isStandalone ? System.getProperty(key, def) :
(getParameter(key) != null ? getParameter(key) : def);
}

//Construct the applet
public Applet1() {
}

//Initialize the applet
public void init() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}

//Component initialization
private void jbInit() throws Exception {
label1.setText("label1");
button1.setLabel("button1");
button1.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(ActionEvent e) {
button1_actionPerformed(e);
}
});
this.add(label1, null);
this.add(button1, null);
}

//Get Applet information
public String getAppletInfo() {
return "Applet Information";
}

//Get parameter info
public String[][] getParameterInfo() {
return null;
}

void button1_actionPerformed(ActionEvent e) {
Count++;
label1.setText(String.valueOf(Count));
}
}

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧