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() {
132
132
textPanel .add (textPane );
133
133
134
134
scrollPane = new JScrollPane (textPanel );
135
- scrollPane .setPreferredSize (new Dimension (600 , 600 ));
136
135
137
136
// 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 ());
139
138
final int charWidth = fm .charWidth ('a' );
140
139
final int lineHeight = fm .getHeight ();
140
+ scrollPane .setPreferredSize (new Dimension (charWidth * 80 , lineHeight * 10 )); //80 columns, 10 lines
141
141
scrollPane .getHorizontalScrollBar ().setUnitIncrement (charWidth );
142
142
scrollPane .getVerticalScrollBar ().setUnitIncrement (2 * lineHeight );
143
143
textPane .setComponentPopupMenu (initMenu ());
Original file line number Diff line number Diff line change 46
46
import javax .swing .JColorChooser ;
47
47
import javax .swing .JDialog ;
48
48
import javax .swing .JPanel ;
49
+ import javax .swing .UIManager ;
49
50
import javax .swing .colorchooser .AbstractColorChooserPanel ;
50
51
51
52
import org .scijava .plugin .Plugin ;
@@ -66,7 +67,7 @@ public class SwingColorWidget extends SwingInputWidget<ColorRGB> implements
66
67
ActionListener , ColorWidget <JPanel >
67
68
{
68
69
69
- private static final int SWATCH_WIDTH = 64 , SWATCH_HEIGHT = 16 ;
70
+ private static final int SWATCH_WIDTH = 64 , SWATCH_HEIGHT = widgetHeight () ;
70
71
71
72
private static final String HSB_CLASS_NAME =
72
73
"javax.swing.colorchooser.DefaultHSBChooserPanel" ;
@@ -211,6 +212,15 @@ private int value(final Object o) {
211
212
return chooser ;
212
213
}
213
214
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
+
214
224
// -- AbstractUIInputWidget methods ---
215
225
216
226
@ Override
You can’t perform that action at this time.
0 commit comments