更新时间:2023-12-05 16:32:58
您正在使用我们无法访问的第三方/自定义组件,因此无法提供任何真实"的解决方案. ..
You're using 3rd party/custom components, to which we don't have access to, so it's impossible to provide any "real" solutions, however...
但是,当按下loadImage按钮时,图像永远不会更新
However the image never gets updated when the loadImage button is pressed
这可能有多种原因,假设图像已正确加载,则可能是:
This could be for any number of reasons, assuming that the image was loaded correctly, its possible that:
repaint
,它应该"触发一个新的绘制过程(不是图像,而是用来渲染它的东西)revalidate
,以触发新的布局遍历,如果正确构建了UI,则会更新组件层次结构.repaint
on the component you want updated, which "should" trigger a new paint pass (not the image, but what ever is been used to render it)revalidate
on the component used to display the image to trigger a new layout pass, which, if you've built your UI correctly, will update the component hierarchy.我的JScrollbar也没有出现在我想要的框架中.它没有滚动槽,并且与我的图像窗口没有相同的宽度.如何更改JScrollbar的参数以反映这一点?
Also my JScrollbar does not appear in the frame as I want it. It does not scroll trough and does not have the same width as my image window. How do I change the parameters of my JScrollbar to reflect that?
这是一个更为复杂的问题.首先,您应该在建立UI后在框架上调用setVisible
,否则它可能无法布局/绘制内容(除非您手动调用revalidate
/repaint
).
That's a much more complicated issue. First, you should call setVisible
on your frame AFTER you've established the UI, otherwise it may not layout/paint the contents (unless you call revalidate
/repaint
manually).
您不需要使用JScrollBar
,而是应该使用JScrollPane
.
You shouldn't need to use JScrollBar
, but instead, should be using JScrollPane
.
强烈建议您先通读以下内容:
I would, strongly, recommend you start by reading through:
以更好地基本了解UI的API和组件
to get a better basic understand of the UI its API and components