Class LookAndFeelList

java.lang.Object
bibliothek.gui.dock.support.lookandfeel.LookAndFeelList

public class LookAndFeelList extends Object
A list of LookAndFeels, can setup a LookAndFeel when asked. It's possible to add a LookAndFeelListener to this list and receive events whenever the LookAndFeel changes.
Clients should use getDefaultList() to get a list of LookAndFeels
Author:
Benjamin Sigg
  • Constructor Details

    • LookAndFeelList

      protected LookAndFeelList()
      Crates a new list and collects all available LookAndFeels.
  • Method Details

    • getDefaultList

      public static LookAndFeelList getDefaultList()
      Gets the global list of LookAndFeels
      Returns:
      the global list, not null
    • setDefaultList

      public static void setDefaultList(LookAndFeelList list)
      Sets the default LookAndFeelList.
      Parameters:
      list - the list, can be null
    • isAllowReadOnlyOnce

      public boolean isAllowReadOnlyOnce()
      Whether multiple calls to read(DataInputStream) have an effect or not.
      Returns:
      true if only the first read-call has an effect.
    • setAllowReadOnlyOnce

      public void setAllowReadOnlyOnce(boolean allowReadOnlyOnce)
      Sets whether multiple calls to read(DataInputStream) will have an effect.
      Parameters:
      allowReadOnlyOnce - true if only the first read will have an effect, false if the LookAndFeel can change every time read(DataInputStream) is called.
    • setReadOnce

      public void setReadOnce(boolean read)
      Sets whether this list has already read something once, or whether it is fresh. Can be used to reset a list to its initial state.
      Parameters:
      read - true if at least one time one of the read methods was called, false otherwise.
    • addLookAndFeelListener

      public void addLookAndFeelListener(LookAndFeelListener listener)
      Adds a listener to this list, the listener will be notified whenever the LookAndFeel is changed.
      Parameters:
      listener - the new listener
    • removeLookAndFeelListener

      public void removeLookAndFeelListener(LookAndFeelListener listener)
      Removes a listener from this list.
      Parameters:
      listener - the listener to remove
    • listeners

      protected LookAndFeelListener[] listeners()
      Gets all LookAndFeelListener that are known to this list.
      Returns:
      the list of listeners
    • addComponentCollector

      public void addComponentCollector(ComponentCollector c)
      Adds a set of root-Components to this list, the set of roots will be used to find all JComponents which need to be updated when the LookAndFeel changes.
      Parameters:
      c - the new set of roots
    • removeComponentCollector

      public void removeComponentCollector(ComponentCollector c)
      Removes an earlier added set of roots.
      Parameters:
      c - the roots
    • add

      public void add(LookAndFeelList.Info info)
      Adds a new LookAndFeel to the list.
      Parameters:
      info - the new LookAndFeel
    • insert

      public void insert(int index, LookAndFeelList.Info info)
      Inserts a new LookAndFeel into the list.
      Parameters:
      index - the location of the new LookAndFeel
      info - the new LookAndFeel
    • size

      public int size()
      Gets the number of LookAndFeels that are known to this list.
      Returns:
      the number of LookAndFeels
    • get

      public LookAndFeelList.Info get(int index)
      Gets the index'th LookAndFeel.
      Parameters:
      index - the location of the LookAndFeel
      Returns:
      the LookAndFeel
    • indexOf

      public int indexOf(LookAndFeelList.Info info)
      Gets the location of info.
      Parameters:
      info - a LookAndFeel
      Returns:
      the location of info or -1
    • getFull

      public LookAndFeelList.Info getFull(int index)
      Gets the index'th LookAndFeel, where 0 means the default, 1 the system and anything else the normal, moved by 2 steps, LookAndFeels.
      Parameters:
      index - the location of the LookAndFeel
      Returns:
      the selected LookAndFeel
    • indexOfFull

      public int indexOfFull(LookAndFeelList.Info info)
      Gets the index of info, where 0 means the default, 1 the system and anything else the normal, moved by 2 steps, LookAndFeels.
      Parameters:
      info - the LookAndFeel to search
      Returns:
      the location of info
    • getFull

      public LookAndFeelList.Info getFull(String key)
      Gets the LookAndFeel whose unique identifier is key.
      Parameters:
      key - the key to search
      Returns:
      the handler of the LookAndFeel or null if key was not found
    • keyOfFull

      public String keyOfFull(LookAndFeelList.Info info)
      Gets a unique identifier for info.
      Parameters:
      info - the item whose identifier is searched
      Returns:
      a unique identifier describing info
    • remove

      public void remove(LookAndFeelList.Info info)
      Removes the LookAndFeel at location index from this list.
      Parameters:
      info - the LookAndFeel to remove
    • remove

      public void remove(int index)
      Removes a LookAndFeel from this list.
      Parameters:
      index - the location of the element to remove
    • getLookAndFeel

      public LookAndFeelList.Info getLookAndFeel()
      Gets the LookAndFeel which is currently used.
      Returns:
      the currently used LookAndFeel
    • setLookAndFeel

      public void setLookAndFeel(LookAndFeelList.Info lookAndFeel)
      Exchanges the currently used LookAndFeel.
      Parameters:
      lookAndFeel - information about a LookAndFeel, not null
    • getDefault

      public LookAndFeelList.Info getDefault()
      Gets information about the LookAndFeel that is used when the system can decide on its own.
      Returns:
      information about a LookAndFeel
    • setDefault

      public void setDefault(LookAndFeelList.Info defaultInfo)
      Sets the default- LookAndFeel. Please note that getDefault() will return another LookAndFeelList.Info, even if the behavior of that other info is the same as defaultInfo.
      Parameters:
      defaultInfo - the default LookAndFeel
    • getSystem

      public LookAndFeelList.Info getSystem()
      Gets information about the LookAndFeel that imitates the native look of the system.
      Returns:
      information about a LookAndFeel
    • setSystem

      public void setSystem(LookAndFeelList.Info systemInfo)
      Sets the system- LookAndFeel. Please note that getSystem() will return another LookAndFeelList.Info, even if the behavior of that other info is the same as systemInfo.
      Parameters:
      systemInfo - the system LookAndFeel
    • write

      public void write(DataOutputStream out) throws IOException
      Writes which LookAndFeel is currently used.
      Parameters:
      out - the stream to write into
      Throws:
      IOException - if the method can't write into out
    • read

      public void read(DataInputStream in) throws IOException
      Reads which LookAndFeel was used earlier and calls setLookAndFeel to set the old LookAndFeel.
      Parameters:
      in - the stream to read from
      Throws:
      IOException - if in can't be read
    • writeXML

      public void writeXML(XElement element)
      Writes which LookAndFeel is currently used.
      Parameters:
      element - the element to write into, the attributes of element will not be changed.
    • readXML

      public void readXML(XElement element)
      Reads which LookAndFeel was used earlier and calls setLookAndFeel to set the old LookAndFeel.
      Parameters:
      element - the element to read from
    • listComponents

      protected Collection<Component> listComponents()
      Creates a list containing all root-Components of this application, the ComponentCollectors are used to build this list.
      Returns:
      the list of roots