如何使用Java中的结构将矩形添加到jscrollpane中
我正在尝试用java做一个简单的幻灯片放映程序,正如你在图片中看到的:
我想添加小矩形,它将幻灯片像幻灯片一样显示在左侧。
在左侧,有一个 JScrollPane
但我不知道应该如何添加显示幻灯片内容的缩略图。
我该怎么做呢?
谢谢
I'm trying to do a simple slide show program in java, and as you see in the image:
I want to add small rectangle's, which shows the slides like a powerpoint to a left side.
In left side, there is a JScrollPane
but I don't know how should I add a thumbnail which shows slide's contents.
How should I do that ?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会为您的图像创建 ImageIcons。您可以在 JScrollPane 中的 JList 中或在使用 GridLayout 并包含包含图标的 JLabels 的 JPanel 中显示它们,同样全部在 JScrollPane 中。我本人非常喜欢 JList 解决方案,因为它使通过鼠标单击选择图像变得更加容易。
与通常的此类 Swing GUI 问题一样,Swing 教程应该向您展示如何执行所有这些操作。
编辑:您对安德鲁·汤普森的评论是一个完全不同的问题,应该在您的原始帖子中提到。有关更多信息,请查看这篇文章:图像获取缩放实例的危险
I would create ImageIcons of your images. You could show them in a JList in a JScrollPane or in a JPanel that uses GridLayout and that holds JLabels that hold the icons, again all in a JScrollPane. Myself, I much favor the JList solution as it makes it much easier to be able to select an image on mouse click.
As usual for this type of Swing GUI issue, the Swing tutorials should show you how to do all these things.
Edit: your comment to Andrew Thompson is a completely different issue and should have been mentioned in your original post. For more on that, please check out this article: perils-of-image-getscaledinstance