单击下一步后无法更改 jScrollPane 中的图像 [英] Unable to change image in jScrollPane upon clicking next
本文介绍了单击下一步后无法更改 jScrollPane 中的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在制作一个 jframe,我正在添加一个图像,该图像将在我单击下一步时发生变化.我编写了一个代码,但它不起作用.代码如下:
I'm making a jframe where i'm adding an image that will change as i click next.I have written a code but it doesn't work.Here is the code:
i++;
ImageIcon icon = new ImageIcon(mean.get(0));
Image image = icon.getImage(); // transform it
Image newimg = image.getScaledInstance(180, 140, java.awt.Image.SCALE_SMOOTH); // scale it the smooth way
icon = new ImageIcon(newimg);
JLabel label = new JLabel( icon );
jScrollPane1= new JScrollPane( label );
请帮忙
推荐答案
问题出在:
jScrollPane1= new JScrollPane( label );
将对象放置在 JFrame 中的字段 jScrollPane
设置为另一个 JScrollPane,其对象未添加到 GUI 中.
The field jScrollPane
whose object was placed in the JFrame is set to another JScrollPane, whose object is not added in the GUI.
将原始标签存储在一个字段中,例如 jLabel1
并设置该标签.
Store the original label in a field, say jLabel1
and set that label.
可能需要重绘
.
这篇关于单击下一步后无法更改 jScrollPane 中的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文