开发者

Displaying thumbnails as a grid

I have an application where I have to display images as t开发者_如何学编程humbnails in a grid and when the users click on one of them , the original picture should be displayed in JAVA. I dont have an

idea as to how to display the thumbnails present in the folder in the form of grid. Any help as to how to start and some sample codes and links would be welcome.


Work on one thing at a time.

  1. Read about LayoutManagers and build a program that will lay out components in a grid.
  2. Figure out how to read images and create a thumbnail. Add that to your program.
  3. Mess with JDialog and creating popups. Also look at Action classes and ActionListeners to tie creating a popup to a button click.


Are you working in Swing? What part do you have problems with? If it's the layout, you can start with the GridLayout

Depending on how you want to implement the zoom, a Frame will be useful.

And to display the bitmaps, a Label will do.


If you need a JComponent, you can try a JTable. If you want a Layout, look at the GridLayout.


You can use Nebula Gallery Widget if you use SWT


I recently had the same requirement - and looked into using Flowlayout. Unfortunately - as this page here describes - http://tips4java.wordpress.com/2008/11/06/wrap-layout/ - it doesnt behave as we'd like.

Fortunately you can grab source for the 'WrapLayout' from the same page.

When it comes to loading images into your panel, for performance I recommend using a SwingWorker as explained here - http://docs.oracle.com/javase/tutorial/uiswing/components/icon.html#efficiency


Have a look at JFlow it's not exactly what you were asking for but pretty close, and all done for you!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜