将JDialog设为modal之后,不能改变JDialog上的JLabel的Text。困扰我好几天了,一直找不到解决方法
例程如下:
import javax.swing.*;
public class TestMontior {
private JDialog dialog;
private ProgressMonitor m;
private JLabel text;
public TestMontior(JFrame parent) {
dialog = new JDialog(parent);
text = new JLabel("text");
dialog.add(text);
dialog.setModal(true);
dialog.setSize(400, 300);
dialog.setVisible(true);
}
public void setText(String value) {
text.setText(value);
}
public static void main(String args[]) {
TestMontior progress = new TestMontior(new JFrame());
progress.setText("new text");
}
}
如果dialog为无模式对话框则可以改变JLabel的text,请问一下这是什么原因?有什么解决方法?