Skip to content

Commit 01459f8

Browse files
committed
SwingColorWidget: Do not use harwired height
Define height relative to font size currently in use. This ensures it adopts the same height as other widgets in hiDPI screens
1 parent 95bc9b3 commit 01459f8

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/main/java/org/scijava/ui/swing/widget/SwingColorWidget.java

+11-1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import javax.swing.JColorChooser;
4747
import javax.swing.JDialog;
4848
import javax.swing.JPanel;
49+
import javax.swing.UIManager;
4950
import javax.swing.colorchooser.AbstractColorChooserPanel;
5051

5152
import org.scijava.plugin.Plugin;
@@ -66,7 +67,7 @@ public class SwingColorWidget extends SwingInputWidget<ColorRGB> implements
6667
ActionListener, ColorWidget<JPanel>
6768
{
6869

69-
private static final int SWATCH_WIDTH = 64, SWATCH_HEIGHT = 16;
70+
private static final int SWATCH_WIDTH = 64, SWATCH_HEIGHT = widgetHeight();
7071

7172
private static final String HSB_CLASS_NAME =
7273
"javax.swing.colorchooser.DefaultHSBChooserPanel";
@@ -211,6 +212,15 @@ private int value(final Object o) {
211212
return chooser;
212213
}
213214

215+
private static int widgetHeight() {
216+
try {
217+
return UIManager.getFont("TextField.font").getSize();
218+
} catch (final Exception ignored) {
219+
// do nothing
220+
}
221+
return 16;
222+
}
223+
214224
// -- AbstractUIInputWidget methods ---
215225

216226
@Override

0 commit comments

Comments
 (0)