Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Laf fixes #79

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/main/java/org/scijava/ui/swing/console/ConsolePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,12 @@ private synchronized void initGui() {
textPanel.add(textPane);

scrollPane = new JScrollPane(textPanel);
scrollPane.setPreferredSize(new Dimension(600, 600));

// Make the scroll bars move at a reasonable pace.
final FontMetrics fm = scrollPane.getFontMetrics(scrollPane.getFont());
final FontMetrics fm = scrollPane.getFontMetrics(textPane.getFont());
final int charWidth = fm.charWidth('a');
final int lineHeight = fm.getHeight();
scrollPane.setPreferredSize(new Dimension(charWidth * 80, lineHeight * 10)); //80 columns, 10 lines
scrollPane.getHorizontalScrollBar().setUnitIncrement(charWidth);
scrollPane.getVerticalScrollBar().setUnitIncrement(2 * lineHeight);
textPane.setComponentPopupMenu(initMenu());
Expand Down
12 changes: 11 additions & 1 deletion src/main/java/org/scijava/ui/swing/widget/SwingColorWidget.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import javax.swing.JColorChooser;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.UIManager;
import javax.swing.colorchooser.AbstractColorChooserPanel;

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

private static final int SWATCH_WIDTH = 64, SWATCH_HEIGHT = 16;
private static final int SWATCH_WIDTH = 64, SWATCH_HEIGHT = widgetHeight();

private static final String HSB_CLASS_NAME =
"javax.swing.colorchooser.DefaultHSBChooserPanel";
Expand Down Expand Up @@ -211,6 +212,15 @@ private int value(final Object o) {
return chooser;
}

private static int widgetHeight() {
try {
return UIManager.getFont("TextField.font").getSize();
} catch (final Exception ignored) {
// do nothing
}
return 16;
}

// -- AbstractUIInputWidget methods ---

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ else if (model.isStyle(NumberWidget.SLIDER_STYLE)) {
}
spinner.setEditor(new JSpinner.NumberEditor(spinner, format));

Dimension spinnerSize = spinner.getSize();
Dimension spinnerSize = spinner.getPreferredSize();
spinnerSize.width = 50;
spinner.setPreferredSize(spinnerSize);
fixSpinner(type);
Expand Down