简体   繁体   English

如何使图像查看器摆动?

[英]How to make an image Viewer in swing?

I am trying to make an image Viewer like the one shown in the figure below:- 我正在尝试制作如下图所示的图像查看器: -

在此输入图像描述

Before i can start i have following questions in mind :- 在我开始之前,我有以下问题: -

  1. How would i check for the number of images in the target folder so that i can iterate and include all the images in my app. 我如何检查目标文件夹中的图像数量,以便我可以迭代并包含我的应用程序中的所有图像。

  2. Secondly,i am thiking to scale the images down to 75x75 .But what i can't think is that how will i slide the images as scrollbar is moved To be specific,what is the appropriate container for those 75x75 images queue and how that queue is shifted to left or right?(I already know how to get current scrollbar value and add event listeners on it to respond) 其次,我很兴奋将图像缩小到75x75。但我不能想到的是,当滚动条移动时我将如何滑动图像具体来说,这些75x75图像队列的适当容器是什么以及如何排队是向左还是向右移动?(我已经知道如何获取当前滚动条值并在其上添加事件监听器以响应)

To check the number of images in the target folder you can use the File class. 要检查目标文件夹中的图像数量,可以使用File类。

As for the container you might need to create the animation your self. 至于容器,您可能需要创建自己的动画。 There is no a container ready for doing so. 没有容器准备好这样做。

This site ( and book ) has some ideas about it. 这个网站(和书)有一些想法。 I don't know how out-dated it might be though 我不知道它可能会过时

http://filthyrichclients.org/ http://filthyrichclients.org/

Unless I am misunderstanding, making a scrolling list of images is quite simple. 除非我误解,否则制作滚动图像列表非常简单。

First, create a JList with a datamodel that allows images. 首先,使用允许图像的数据模型创建JList。

A great example is shown here: Java drag and drop images in a list 这里显示了一个很好的例子: Java在列表中拖放图像

Second, add the JList to a JScrollPane. 其次,将JList添加到JScrollPane。

The scaling aspect can be easily performed using Scalr: http://www.thebuzzmedia.com/software/imgscalr-java-image-scaling-library/ 使用Scalr可以轻松执行扩展方面: http//www.thebuzzmedia.com/software/imgscalr-java-image-scaling-library/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM