java.lang.Object
com.marginallyclever.donatello.PanelHelper
PanelHelper is a collection of static methods to help build panels.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddCheckbox(JPanel parent, String label, Supplier<Boolean> start, Consumer<Boolean> end, GridBagConstraints gbc) static voidaddColorChooser(JPanel parent, String title, Supplier<Color> startColor, Consumer<Color> consumer, GridBagConstraints gbc) A convenience method to add a color chooser to a panel.static voidaddLabelAndComponent(JPanel pane, String labelText, JComponent component) A convenience method to add a label and component to a panel that is built withGridLayout.static voidaddLabelAndComponent(JPanel pane, String labelText, JComponent component, GridBagConstraints gbc) A convenience method to add a label and component to a panel that is built withGridBagLayout.static voidaddLimit(JPanel pane, GridBagConstraints gbc, String label, double value, Consumer<Double> consumer, double infinite) A convenience method to add an angle limit to a panel (in degrees).static JFormattedTextFieldaddNumberField(String toolTip, double value, NumberFormatter formatter) A convenience method to add a number field to a panel.static JFormattedTextFieldaddNumberFieldDouble(String toolTip, double value) A convenience method to add a number field to a panel.static JFormattedTextFieldaddNumberFieldInt(String toolTip, int value) A convenience method to add a number field to a panel.static voidaddSeparator(JPanel parent, GridBagConstraints gbc) static GridBagConstraintsstatic JComponentcreateRange(double max, double min, double value, Consumer<Double> consumer) Create a range slider with two decimal places that displays the value on the right.static voidenableLimit(boolean isSelected, JSpinner spinner, Consumer<Double> consumer, double infinite)
-
Constructor Details
-
PanelHelper
public PanelHelper()
-
-
Method Details
-
createGBC
-
addLabelAndComponent
A convenience method to add a label and component to a panel that is built with
GridLayout.- Parameters:
pane- the panel to add tolabelText- the text for the labelcomponent- the component to add
-
addLabelAndComponent
public static void addLabelAndComponent(JPanel pane, String labelText, JComponent component, GridBagConstraints gbc) A convenience method to add a label and component to a panel that is built with
GridBagLayout.- Parameters:
pane- the panel to add tolabelText- the text for the labelcomponent- the component to addgbc- the GridBagConstraints to use
-
addColorChooser
public static void addColorChooser(JPanel parent, String title, Supplier<Color> startColor, Consumer<Color> consumer, GridBagConstraints gbc) A convenience method to add a color chooser to a panel.
- Parameters:
parent- the parent paneltitle- the title for the color chooserstartColor- the initial colorconsumer- the consumer to accept the colorgbc- theGridBagConstraintsto use
-
addNumberFieldDouble
A convenience method to add a number field to a panel.
- Parameters:
toolTip- the tooltip for the fieldvalue- the initial value- Returns:
- the
JFormattedTextField
-
addNumberFieldInt
A convenience method to add a number field to a panel.
- Parameters:
toolTip- the tooltip for the fieldvalue- the initial value- Returns:
- the
JFormattedTextField
-
addNumberField
public static JFormattedTextField addNumberField(String toolTip, double value, NumberFormatter formatter) A convenience method to add a number field to a panel.
- Parameters:
toolTip- the tooltip for the fieldvalue- the initial valueformatter- theNumberFormatterto use- Returns:
- the
JFormattedTextField
-
addLimit
public static void addLimit(JPanel pane, GridBagConstraints gbc, String label, double value, Consumer<Double> consumer, double infinite) A convenience method to add an angle limit to a panel (in degrees).
- Parameters:
pane- the panel to add togbc- theGridBagConstraintsto uselabel- the label for the limitvalue- the initial valueconsumer- the consumer to accept the valueinfinite- the value to use for infinite (no limit)
-
enableLimit
-
createRange
public static JComponent createRange(double max, double min, double value, Consumer<Double> consumer) Create a range slider with two decimal places that displays the value on the right.- Parameters:
max- the maximum valuemin- the minimum valuevalue- the initial valueconsumer- the consumer to accept the value- Returns:
- the
JComponent
-
addCheckbox
-
addSeparator
-