Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package hu.kazocsaba.imageviewer;
Utility methods for image viewers.

Kazó Csaba
public class ImageViewerUtil {
Private constructor.
	private ImageViewerUtil() {}
A property change listener that synchronizes the display-related properties of two image viewers.
	private static class PropertySynchronizer implements PropertyChangeListener {
		private final ImageViewer v1,v2;
			this. = v1;
			this. = v2;
		public void propertyChange(PropertyChangeEvent evt) {
			ImageViewer target=source== ?  : ;
			if ("statusBarVisible".equals(evt.getPropertyName())) {
else if ("resizeStrategy".equals(evt.getPropertyName())) {
else if ("zoomFactor".equals(evt.getPropertyName())) {
else if ("pixelatedZoom".equals(evt.getPropertyName())) {
Synchronizes the view state of multiple image viewers with respect to scroll position and resize strategy, and other properties affecting display. For this to work correctly, the viewers should always have the same size.

first the first viewer
others the other viewers
	public static void synchronizeViewers(ImageViewer firstImageViewer... others) {
		for (ImageViewer otherothers) {
			if (other!=first) {
				new PropertySynchronizer(firstother);
New to GrepCode? Check out our FAQ X