The moose likes Swing / AWT / SWT and the fly likes GUI design advice needed for window displaying an image Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "GUI design advice needed for window displaying an image" Watch "GUI design advice needed for window displaying an image" New topic

GUI design advice needed for window displaying an image

Nate Lockwood
Ranch Hand

Joined: Feb 22, 2010
Posts: 83
I have a tool (class) pretty well completed which allows a user to navigate through a possibly long list of our unique image files and choose one to display in a separate window. I need the user to be able to sequentially choose more than one so that they may be compared. I don't really want to keep track of multiple windows in the tool.

The class is named, for now, ImageWindow.java. I expect the displayed image window to have a status bar and a JPanel just below the title bar to display a line of image statistics. I want a popup menu (mouse right click on the image?) and the ability to get the mouse position over the image so that I may display the raw data value.

We will have three or 4 sizes of images with the smaller ones needing to be zoomed in and the larger zoomed out.

I'm still leaning Java and am especially new to GUI code.

I'm not sure exactly how to proceed at this point. I'll have data that cannot be static, I think. Should the ImageWindow extend JPanel, implement MouseMotionListener, and have a main? This would be similar to the example I found. Should I use a different structure?

Darryl Burke

Joined: May 03, 2008
Posts: 4523

From your description of the requirement, I would go with a JFileChooser with a custom accessory.

For displaying all images at the same size you can use a Graphics method that takes the width and height as parameters (watch out for distortion!), or you can use my Stretch Icon class.

Should the ImageWindow ... have a main?

Only if it's meant to be the entry point to the program.

That's not to say you can't have a main(...) method if it's not the entry point; such a method might be useful for a trial, standalone run.

luck, db
There are no new questions, but there may be new answers.
Nate Lockwood
Ranch Hand

Joined: Feb 22, 2010
Posts: 83
Thanks. Since this will not used as a standalone app I'll not use main. I'll keep your stretch class as I'm not sure what the future needs will be with different size displays. Right now I have only a few working samples of images that are all the same size.
Nate Lockwood
Ranch Hand

Joined: Feb 22, 2010
Posts: 83
This is really not working well.
The GUI that will contain the image is ImageWindow and the constructor is

When the user clicks on display a new ImageWindow() is created. I don't know to include screen shots here so I include the PNG files as attachments. (That didn't work; I guess it doesn't like PNG files.).
I'm on Ubuntu; my windows have kind of chocolate colored title bar and whose upper right and upper left corners are rounded a bit. The first window is normal.
Subsequent windows show the correct file name in the title bar but do not have the same appearance. There are icon place holders for maximize, minimize, and close and they are placed on the opposite side of the title bar.

What I want is a few independent display windows so that images may be compared side to side.

I agree. Here's the link: http://aspose.com/file-tools
subject: GUI design advice needed for window displaying an image
Similar Threads
Move enlarged image around on mouseover - Image mapping
Component Please??
another kind of Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space
More Model-View-Controller advice needed
Handling MouseMovement in JTextArea