Skip to content

Commit 2ac8e95

Browse files
committed
Resize wrong-sized search result images
1 parent 7535b38 commit 2ac8e95

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/main/java/org/scijava/ui/swing/search/SwingSearchBar.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import java.awt.Dimension;
3737
import java.awt.Font;
3838
import java.awt.GridLayout;
39+
import java.awt.Image;
3940
import java.awt.Window;
4041
import java.awt.event.ActionListener;
4142
import java.awt.event.FocusEvent;
@@ -701,11 +702,13 @@ private Component icon(final String iconPath) {
701702
}
702703
final URL iconURL = getClass().getResource(iconPath);
703704
if (iconURL == null) return emptyIcon();
704-
final ImageIcon icon = new ImageIcon(iconURL);
705+
ImageIcon icon = new ImageIcon(iconURL);
705706
if (icon.getIconWidth() != ICON_SIZE || //
706707
icon.getIconHeight() != ICON_SIZE)
707708
{
708-
return emptyIcon();
709+
// Resize icon to the needed size.
710+
icon = new ImageIcon(icon.getImage().getScaledInstance(
711+
ICON_SIZE, ICON_SIZE, Image.SCALE_SMOOTH));
709712
}
710713
return new JLabel(icon);
711714
}

0 commit comments

Comments
 (0)