Swing 刷新drawingPanel中的图片扩展了JPanel 2
我很抱歉发布了一条与此类似的帖子。但我仍然有一些问题。细线清晰可见 我正在对jpanel应用反向循环。我需要有一个加载文件,稍后更改为确定或错误图像 我在开始时加载了一张透视图。一旦一个动作监听器开始加载,它就会被替换,在监听器中执行的代码结束时,我用ok/error更改图。透明的,确定的和错误的一个得到完美的加载,但我没有设法看到加载的一个 以下是我的侦听器代码:Swing 刷新drawingPanel中的图片扩展了JPanel 2,swing,asynchronous,refresh,jpanel,Swing,Asynchronous,Refresh,Jpanel,我很抱歉发布了一条与此类似的帖子。但我仍然有一些问题。细线清晰可见 我正在对jpanel应用反向循环。我需要有一个加载文件,稍后更改为确定或错误图像 我在开始时加载了一张透视图。一旦一个动作监听器开始加载,它就会被替换,在监听器中执行的代码结束时,我用ok/error更改图。透明的,确定的和错误的一个得到完美的加载,但我没有设法看到加载的一个 以下是我的侦听器代码: void refreshButtonActionPerformed(java.awt.event.ActionEvent evt)
void refreshButtonActionPerformed(java.awt.event.ActionEvent evt) {
// load loading icon
Image img = new ImageIcon(iconPath+"loading.gif").getImage();
this.iconPanel.replaceImage(img);
this.iconPanel.updateUI();
this.iconPanel.revalidate();
this.iconPanel.repaint();
// clear table contents
designValue.clear();
deployValue.clear();
// Fill class
diagnosticGenerator diagnostic = new diagnosticGenerator();
Vector<Integer> indexes;
// if modeCombo.getSelectedIndex() == 0 i show only data regarding the current user
if (modeCombo.getSelectedIndex() == 0) {
// receive Design Table
designValue.addAll(diagnostic.getDesignContents());
// receive Deploy Table
deployValue.addAll(diagnostic.getDeployContents());
// receive indexes of out-dated deploy
indexes = new Vector<Integer>(diagnostic.getOutdatedDeployIndexes());
}
// otherwise i show data of all the users
else {
// receive Design Table
designValue.addAll(diagnostic.getDesignContents_allUsers());
// receive Deploy Table
deployValue.addAll(diagnostic.getDeployContents_allUsers());
// receive indexes of out-dated deploy
indexes = new Vector<Integer>(diagnostic.getOutdatedDeployIndexes_allUsers());
}
// set default color to green
deployTable.resetColor(Color.white);
// set red background to the
for (Integer x : indexes)
deployTable.setRowColor(x, Color.red);
deployTable.repaint();
designTable.revalidate();
deployTable.revalidate();
//update refreshLabel with the new date
Date date = new Date();
refreshLabel.setText(date.toString());
//replace icon with different mark depending on the fact if we found an error or not
if(indexes.isEmpty())
img = new ImageIcon(iconPath+"ok.png").getImage();
else
img = new ImageIcon(iconPath+"error.png").getImage();
this.iconPanel.replaceImage(img);
this.iconPanel.repaint();
}
我可以看到正在加载的gif。但是我的代码被卡住了。
所以我认为我应该找到一种方法,在那个时候强制执行队列中的所有命令,但我不知道该怎么做
是否有人对swing有类似的问题?使用诸如
ImageIO.read(File/URL/InputStream)
之类的阻塞方法来获取图像ImageIO
最近被引入到J2SE中。很抱歉,我没有得到它。这不是加载图像的问题,问题是我的应用程序没有刷新界面。因为三分之四的时间是有效的。但就在接近“不工作时间”的时候。。。你能给我解释清楚吗你什么意思?tnx:)“你能更好地解释我吗?你是什么意思?”你能帮我发一个帖子吗?
this.iconPanel.repaint();