Class StyleTrait<C extends JComponent>

java.lang.Object
swingtree.style.StyleTrait<C>
Type Parameters:
C - The type of JComponent this StyleTrait is for.

public final class StyleTrait<C extends JComponent> extends Object
A StyleTrait contains a set of properties that will be used to target specific JComponents matching said properties, so that you can associate custom Styler lambdas with them which are using the ComponentStyleDelegate API to configure the style of the component.
See StyleSheet.add(StyleTrait, Styler) for more information.
Instances of this are supposed to be created and registered inside custom StyleSheet extensions, more specifically a StyleSheet.configure() implementation in which you can register your StyleTraits and Stylers using the StyleSheet.add(StyleTrait, Styler) method.
  • Method Details

    • group

      public StyleTrait<C> group(String group)
      Creates a new StyleTrait with the same properties as this one, but with the given group name.
      Note that this method defines the group in terms of a String which can be problematic with respect to compile-time safety.
      Please consider using group(Enum) instead.
      Parameters:
      group - The new group name.
      Returns:
      A new StyleTrait with the same properties as this one, but with the given group name.
    • group

      public <E extends Enum<E>> StyleTrait<C> group(E group)
      Creates a new StyleTrait with the same properties as this one, but with the given group in terms of an Enum.
      Type Parameters:
      E - The type of the Enum to use as the group enum
      Parameters:
      group - The new group in terms of an Enum.
      Returns:
      A new StyleTrait with the same properties as this one, but with the given group name.
    • id

      public StyleTrait<C> id(String id)
      Creates a new StyleTrait with the same properties as this one, but with the given id.
      Note that this method defines the id in terms of a String which can be problematic with respect to compile-time safety.
      Please consider using id(Enum) instead.
      Parameters:
      id - The new id.
      Returns:
      A new StyleTrait with the same properties as this one, but with the given id.
    • id

      public <E extends Enum<E>> StyleTrait<C> id(E id)
      Creates a new StyleTrait with the same properties as this one, but with the given id in terms of an Enum.
      Type Parameters:
      E - The type of the Enum to use as the id enum
      Parameters:
      id - The new id in terms of an Enum.
      Returns:
      A new StyleTrait with the same properties as this one, but with the given id.
    • inherits

      public StyleTrait<C> inherits(String... superGroups)
      Creates a new StyleTrait with the same properties as this one, but with an array of groups to inherit from.
      Note that this method defines the groups in terms of Strings which can be problematic with respect to compile-time safety.
      Please consider using inherits(Enum[]) instead.
      Parameters:
      superGroups - The new groups to inherit from.
      Returns:
      A new StyleTrait with the same properties as this one, but with the given groups to inherit from.
    • inherits

      @SafeVarargs public final <E extends Enum<E>> StyleTrait<C> inherits(E... superGroups)
      Creates a new StyleTrait with the same properties as this one, but with an array of groups to inherit from in terms of Enums.
      Type Parameters:
      E - The type of the Enums to use as the super group enums
      Parameters:
      superGroups - The new groups to inherit from in terms of Enums.
      Returns:
      A new StyleTrait with the same properties as this one, but with the given groups to inherit from.
    • type

      public <T extends C> StyleTrait<T> type(Class<T> type)
      Creates a new StyleTrait with the same properties as this one, but with the given component type to which a style should be applied.
      Type Parameters:
      T - The type of the JComponent to use as the type
      Parameters:
      type - The new type.
      Returns:
      A new StyleTrait with the same properties as this one, but with the given type.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object