X-Git-Url: http://gitweb.fperrin.net/?p=GpsPrune.git;a=blobdiff_plain;f=tim%2Fprune%2Fgui%2FPhotoThumbnail.java;h=cc7e776e224aa4bb93a3bb3831faac5c42c457c3;hp=88e77ca58ce6795986185604435eb59e317a6b8e;hb=6814c830d470f73c7ec57c71235de333f5ea4279;hpb=c0387c124840c9407e040600fda88f3c3e8f6aa6 diff --git a/tim/prune/gui/PhotoThumbnail.java b/tim/prune/gui/PhotoThumbnail.java index 88e77ca..cc7e776 100644 --- a/tim/prune/gui/PhotoThumbnail.java +++ b/tim/prune/gui/PhotoThumbnail.java @@ -7,6 +7,7 @@ import java.awt.Image; import java.awt.image.BufferedImage; import javax.swing.ImageIcon; import javax.swing.JPanel; +import javax.swing.SwingUtilities; import tim.prune.I18nManager; import tim.prune.data.Photo; @@ -88,10 +89,19 @@ public class PhotoThumbnail extends JPanel implements Runnable int horizOffset = (getWidth() - scaleWidth) / 2; int vertOffset = (getHeight() - scaleHeight) / 2; inG.drawImage(scaled, horizOffset, vertOffset, scaleWidth, scaleHeight, null); - if (getHeight() < getWidth()) + if (getHeight() < getWidth() || getHeight() > usableWidth) { - setPreferredSize(new Dimension(usableWidth, usableWidth)); + Dimension newsize = new Dimension(usableWidth, usableWidth); + setPreferredSize(newsize); + setSize(newsize); invalidate(); + // Schedule a relayout because the size has changed + SwingUtilities.invokeLater(new Runnable() { + public void run() { + try {Thread.sleep(200);} catch (InterruptedException e) {} + getParent().getParent().getParent().validate(); + } + }); } } }