[英]show more than one picture in a panel
I am trying to make a photo viewer ,and I meet some problem . 我正在尝试制作照片查看器,但遇到了一些问题。
I want to show more than one pic once time in a Panel . 我想在面板中一次显示多个图片。 But I could't do it well , in my project (you will see in pic1 ), it show all the pictures in a small space ,so all the picture become too small to see.
但是我做得不好,在我的项目中(您将在pic1中看到),它在一个很小的空间中显示了所有图片,因此所有图片都变得太小而看不到。 I try to solve it by adding the GridLaout to a JScrollPanel ,bu it could't work .
我尝试通过将GridLaout添加到JScrollPanel来解决此问题,但无法正常工作。
I want to know how to solve it , to show several pictures in a Panel once time.Not why I could't add a GridLaout to a JScrollPanel. 我想知道如何解决它,一次在Panel中显示几张图片。这不是为什么我不能将GridLaout添加到JScrollPanel的原因。
This is a part of my code[ It just a part and your could't use to to debug ,it's my idea of my project] 这是我的代码的一部分[这只是一部分,您不能用来调试,这是我对项目的想法]
grid = new GridLayout(0, 4);
pane3.setLayout(grid);
ImageIcon ico = new ImageIcon("c:\\picture\\abc.jpg");
JLabel tmp = new JLabel(ico);
pane3.add(tmp);
If you know how to do it ,please contact me.Thans. 如果您知道该怎么做,请与我联系。
This is a good perform that I want to achieve 我想要达到的出色表现
This one is my project perform ,it work baddly 这是我的项目执行,工作很糟糕
The key problem you seem to be having, is you've not put your base component into a JScrollPane
, so GridLaout
has divided the available space evenly amongst the components. 您似乎遇到的关键问题是,您没有将基本组件放入
JScrollPane
,因此GridLaout
在组件之间平均分配了可用空间。
See How to Use Scroll Panes for more details. 有关更多详细信息,请参见如何使用滚动窗格 。
You could also have a look at this example which does something simular 您也可以看看这个例子 ,它做了一些类似的事情
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.