Package sc.fiji.snt.gui
Class GuiUtils.Fields
java.lang.Object
sc.fiji.snt.gui.GuiUtils.Fields
- Enclosing class:
GuiUtils
Utility methods for creating and reading
JSpinners and JTextFields.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddClearButton(JTextField textField) static voidaddPlaceholder(JTextField textField, String placeholder) static JSpinnerdoubleSpinner(double value, double min, double max, double step, int nDecimals) static JSpinnerdoubleSpinner(double value, double min, double max, double step, int nDecimals, boolean proportionalSteps) Same asdoubleSpinner(double, double, double, double, int), optionally with proportional steps: each arrow click changes the value by the larger ofstepand 10% of the current value (clamped to the range), which keeps wide ranges navigablestatic doubleextractDouble(JTextField textfield) static JSpinnerintegerSpinner(int value, int min, int max, int step, boolean allowEditing) static JPanelwithDefaultButton(JSpinner spinner, Number defaultValue) Pairsspinnerwith a borderless "reset to default" button (undo glyph).
-
Constructor Details
-
Fields
public Fields()
-
-
Method Details
-
integerSpinner
-
doubleSpinner
public static JSpinner doubleSpinner(double value, double min, double max, double step, int nDecimals) -
doubleSpinner
public static JSpinner doubleSpinner(double value, double min, double max, double step, int nDecimals, boolean proportionalSteps) Same asdoubleSpinner(double, double, double, double, int), optionally with proportional steps: each arrow click changes the value by the larger ofstepand 10% of the current value (clamped to the range), which keeps wide ranges navigable -
withDefaultButton
Pairsspinnerwith a borderless "reset to default" button (undo glyph). Pressing it sets the spinner todefaultValue, so anyChangeListenerregistered on the spinner fires as if the user had typed the value. The caller keeps usingspinneritself for listeners/values and only adds the returned panel to its layout. The button is enabled only while the spinner is.- Parameters:
spinner- the spinner (its model must be aSpinnerNumberModelor acceptdefaultValue)defaultValue- the value restored by the button. It should match the model's number type- Returns:
- a panel holding the spinner and the reset button
-
extractDouble
-
addClearButton
-
addPlaceholder
-