你可以用pl.updateUI()来更新。
Swing是no-thread-safe的
因此,只能在event-dispatching-thread中对Swing Component进行操作
Swing是no-thread-safe的
因此,只能在event-dispatching-thread中对Swing Component进行操作
解决方案 »
- 收集各种文件类型的文件头信息
- 年前面试软件园一家小公司的22道选择题
- 一个uncode字符串,这个字符串按照某种编码规则被编码过一次, 请用Java编程将此字串解码 要怎么办呢?
- 再帮我看一段代码,马上结贴
- 怎样使用Random类比如比较两个随机数大小??????
- Object到int的类型转换问题!
- 再提一个.字符串问题.大家帮帮忙吧~~~~~~~!
- 关于Exception的经典问题,欢迎高手来讨论。在线等待,下午接分。
- 如何迈过java学习的第二个门槛??!求教。
- 请问谁有那种能根据所给数值实时变化的曲线图的applet啊?一定给分!
- java中如何将一个对象写入一个文件中?
- 小生不才,有几个学Thing in java 遇到的问题,请大侠帮于小生脱离苦海。 初学者
p1.invalidate();
p1.validate();
<------ 树欲静而风不止 ------>
invalidate();
updateUI();
换着试试.
import javax.swing.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.*;/**
* Created by IntelliJ IDEA.
* User: purples
* Date: 2003-12-23
* Time: 16:42:59
* To change this template use Options | File Templates.
*/
//main panel show in NodeModifyDlg to modify node,or it could use to instead node add panel
public class NodeModifyDlg extends JDialog implements ActionListener{ public void actionPerformed(ActionEvent event){
String command = event.getActionCommand();
if(command.equals("close")){
this.dispose();
if(DEBUG == true){
System.out.println("close");
}
}
} public NodeModifyDlg(Frame frame, boolean model, boolean isAdd){
super(frame, model);
init(true, isAdd);
}
//default is model,not node add dialog
public NodeModifyDlg(Frame frame){
super(frame, true);
init(false, false);
} public NodeModifyDlg(Dialog dialog, boolean model, boolean isAdd){
super(dialog, model);
init(false, isAdd);
} public NodeModifyDlg(Dialog dialog){
super(dialog,true);
init(false, false);
} protected void init(boolean debug, boolean isAdd){
DEBUG = debug;
this.isAdd = isAdd;
jbinit();
} //init the GUI
private void jbinit(){
Container c = this.getContentPane();
//datePane draw
datePane = new JPanel();
datePane.setLayout(new FlowLayout(FlowLayout.LEFT,10,5));
timeLabel = new JLabel("Register Date:"+new java.util.Date()); //todo: need getData() to replace
updateLabel = new JLabel("Update Date:");//need getUpdateData() to add
datePane.add(timeLabel);
datePane.add(updateLabel);
//datePane finished
//tabPane draw
tabPane = new JTabbedPane();
tabPane.addTab("Basic info", basicPane);
tabPane.addTab("Control info", controlPane);
//button draw
nodeOk = new JButton("Ok");
nodeClose = new JButton("Close");
nodeOk.setActionCommand("ok");
nodeClose.setActionCommand("close");
nodeOk.addActionListener(this);
nodeClose.addActionListener(this);
buttonPane = new JPanel();
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT,10,10));
buttonPane.add(nodeOk);
buttonPane.add(nodeClose);
//button draw finished c.setLayout(new BorderLayout(10,10));
if(isAdd == false){
setTitle("Node Modify");
c.add(BorderLayout.NORTH, datePane);
}
else{
setTitle("Node Add");
}
makeTabPane();
// tabPane.invalidate();
// tabPane.validate();
c.add(BorderLayout.CENTER,tabPane);
// basicNorthPane.invalidate();
// basicNorthPane.validate();
// basicNorthPane.repaint();
// tabPane.updateUI();
c.add(BorderLayout.SOUTH, buttonPane);
} private void makeTabPane(){
basicPaneInit();
controlPaneInit();
} private void basicPaneInit(){
basicPane = new JPanel();
basicNorthPane = new JPanel();
basicNorthPane.setLayout(new FlowLayout(FlowLayout.LEFT));
locationLabel = new JLabel("Location");
locationComboBox = new JComboBox();
//todo: add item to comboBox here
basicNorthPane.add(locationLabel);
basicNorthPane.add(locationComboBox); basicPane.setLayout(new BorderLayout());
basicPane.add( BorderLayout.NORTH, basicNorthPane); } private void controlPaneInit(){
controlPane = new JPanel();
} public void setDEBUG(boolean DEBUG) {
this.DEBUG = DEBUG;
} private boolean isAdd;
private JPanel datePane;
private JLabel timeLabel;
private JLabel updateLabel;
private JTabbedPane tabPane;
private JPanel basicPane;
private JPanel controlPane; private JPanel basicNorthPane;
private JPanel basicCenterPane;
private JPanel basicEastPane;
private JPanel basciSouthPane; private JLabel locationLabel;
private JComboBox locationComboBox; private JPanel buttonPane;
private JButton nodeOk;
private JButton nodeClose;
private boolean DEBUG;
}