File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed
src/main/java/org/scijava/ui/swing Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -132,12 +132,12 @@ private synchronized void initGui() {
132132 textPanel .add (textPane );
133133
134134 scrollPane = new JScrollPane (textPanel );
135- scrollPane .setPreferredSize (new Dimension (600 , 600 ));
136135
137136 // Make the scroll bars move at a reasonable pace.
138- final FontMetrics fm = scrollPane .getFontMetrics (scrollPane .getFont ());
137+ final FontMetrics fm = scrollPane .getFontMetrics (textPane .getFont ());
139138 final int charWidth = fm .charWidth ('a' );
140139 final int lineHeight = fm .getHeight ();
140+ scrollPane .setPreferredSize (new Dimension (charWidth * 80 , lineHeight * 10 )); //80 columns, 10 lines
141141 scrollPane .getHorizontalScrollBar ().setUnitIncrement (charWidth );
142142 scrollPane .getVerticalScrollBar ().setUnitIncrement (2 * lineHeight );
143143 textPane .setComponentPopupMenu (initMenu ());
Original file line number Diff line number Diff line change 4646import javax .swing .JColorChooser ;
4747import javax .swing .JDialog ;
4848import javax .swing .JPanel ;
49+ import javax .swing .UIManager ;
4950import javax .swing .colorchooser .AbstractColorChooserPanel ;
5051
5152import 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
You can’t perform that action at this time.
0 commit comments