Class GuiUtils.Fields

java.lang.Object
sc.fiji.snt.gui.GuiUtils.Fields
Enclosing class:
GuiUtils

public static class GuiUtils.Fields extends Object
Utility methods for creating and reading JSpinners and JTextFields.
  • Constructor Details

    • Fields

      public Fields()
  • Method Details

    • integerSpinner

      public static JSpinner integerSpinner(int value, int min, int max, int step, boolean allowEditing)
    • 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 as doubleSpinner(double, double, double, double, int), optionally with proportional steps: each arrow click changes the value by the larger of step and 10% of the current value (clamped to the range), which keeps wide ranges navigable
    • withDefaultButton

      public static JPanel withDefaultButton(JSpinner spinner, Number defaultValue)
      Pairs spinner with a borderless "reset to default" button (undo glyph). Pressing it sets the spinner to defaultValue, so any ChangeListener registered on the spinner fires as if the user had typed the value. The caller keeps using spinner itself 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 a SpinnerNumberModel or accept defaultValue)
      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

      public static double extractDouble(JTextField textfield)
    • addClearButton

      public static void addClearButton(JTextField textField)
    • addPlaceholder

      public static void addPlaceholder(JTextField textField, String placeholder)