Class JXGradientChooser

  • All Implemented Interfaces:
    ImageObserver, MenuContainer, Serializable, Accessible, Scrollable

    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

    Author:
    joshy
    See Also:
    Serialized Form
    • Constructor Detail

      • JXGradientChooser

        public JXGradientChooser()
        Creates new JXGradientChooser
    • Method Detail

      • 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.
      • 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