Class JXGradientChooser

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, Scrollable, AlphaPaintable, BackgroundPaintable

@JavaBean public class JXGradientChooser extends JXPanel

A specialized JXPanel that allows the user to construct and choose a Gradient. The returned values will be one of: LinearGradientPaint or RadialGradientPaint.

Dependency: Because this class relies on LinearGradientPaint and RadialGradientPaint, it requires the optional MultipleGradientPaint.jar

See Also:
  • Field Details

    • slider

      private JXMultiThumbSlider<Color> slider
      The multi-thumb slider to use for the gradient stops
    • deleteThumbButton

      private JButton deleteThumbButton
    • addThumbButton

      private JButton addThumbButton
    • colorField

      private JTextField colorField
    • changeColorButton

      private JXColorSelectionButton changeColorButton
    • colorLocationSpinner

      private JSpinner colorLocationSpinner
    • alphaSpinner

      private JSpinner alphaSpinner
    • alphaSlider

      private JSlider alphaSlider
    • styleCombo

      private JComboBox styleCombo
    • gradientPreview

      private GradientPreviewPanel gradientPreview
    • noCycleRadio

      private JRadioButton noCycleRadio
    • reflectedRadio

      private JRadioButton reflectedRadio
    • repeatedRadio

      private JRadioButton repeatedRadio
    • reversedCheck

      private JCheckBox reversedCheck
    • gradient

      private MultipleGradientPaint gradient
    • thumbsMoving

      private boolean thumbsMoving
    • log

      private Logger log
    • topPanel

      private JPanel topPanel
      This method is called from within the constructor to initialize the form.
    • previewPanel

      private JPanel previewPanel
      This method is called from within the constructor to initialize the form.
  • Constructor Details

    • JXGradientChooser

      public JXGradientChooser()
      Creates new JXGradientChooser
  • Method Details

    • getGradient

      public MultipleGradientPaint getGradient()
      Returns the MultipleGradientPaint currently choosen by the user.
      Returns:
      the currently selected gradient
    • setGradient

      public void setGradient(MultipleGradientPaint mgrad)
      Sets the gradient within this panel to the new gradient. This will delete the old gradient all of it's settings, resetting the slider, gradient type selection, and other gradient configuration options to match the new gradient.
      Parameters:
      mgrad - The desired gradient.
    • recalcGradientFromStops

      private void recalcGradientFromStops()
    • updateFromStop

      private void updateFromStop(Thumb<Color> thumb)
    • updateFromStop

      private void updateFromStop(int thumb, float position, Color color)
    • updateDeleteButtons

      private void updateDeleteButtons()
    • updateGradientProperty

      private void updateGradientProperty()
    • initComponents

      private void initComponents()
    • initComponents2

      private void initComponents2()
    • selectColorForThumb

      private void selectColorForThumb()
    • showDialog

      public static MultipleGradientPaint showDialog(Component comp, String title, MultipleGradientPaint mgrad)
      This static utility method cannot be called from the ETD, or your application will lock up. Call it from a separate thread or create a new Thread with a Runnable.
      Parameters:
      comp - The component to use when finding a top level window or frame for the dialog.
      title - The desired title of the gradient chooser dialog.
      mgrad - The gradient to initialize the chooser too.
      Returns:
      The gradient the user chose.
    • toString

      public static String toString(MultipleGradientPaint paint)
      Creates a string representation of a MultipleGradientPaint. This string is used for debugging purposes. Its contents cannot be guaranteed between releases.
      Parameters:
      paint - the paint to create a string for
      Returns:
      a string representing the supplied paint