Class PreferencesEntry<T>

java.lang.Object
net.mcreator.preferences.PreferencesEntry<T>
Type Parameters:
T -

The type of the stored value.

Direct Known Subclasses:
BooleanEntry, ColorEntry, HiddenEntry, IntegerEntry, LocaleEntry, StringEntry

public abstract class PreferencesEntry<T> extends Object

This is the basic and the common class for all preferences of the software. It stores everything the preference needs to have to be used or saved, such as an ID, its value or its JComponent for PreferencesDialog. This is also the class used to save each preference inside the user's folder. However, only required (fields without transient) fields are saved.

  • Field Details

    • value

      protected T value
  • Constructor Details

    • PreferencesEntry

      public PreferencesEntry(String id, T value)
  • Method Details

    • getComponent

      public abstract JComponent getComponent(Window parent, Consumer<EventObject> fct)

      Generate a JComponent for the PreferencesDialog, so users can change the value.

      Parameters:
      parent -

      The component's parent, which is the opened PreferencesDialog.

      fct -

      This is the Consumer used to enable the apply button when the value of the JComponent is changed.

      Returns:

      The JComponent to use inside the PreferencesDialog for all preference entries using the same type.

    • setValueFromComponent

      public abstract void setValueFromComponent(JComponent component)
    • setValueFromJsonElement

      public abstract void setValueFromJsonElement(com.google.gson.JsonElement object)
    • getSerializedValue

      public abstract com.google.gson.JsonElement getSerializedValue()
    • getID

      public String getID()
    • get

      public T get()
    • reset

      public void reset()
    • set

      public void set(T newValue)
    • getSectionKey

      public String getSectionKey()
    • getSection

      public PreferencesSection getSection()
    • toString

      public String toString()
      Overrides:
      toString in class Object