Class Chatter

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, Buildable, CommandEncoder
Direct Known Subclasses:
PrivateChatter

public class Chatter
extends JPanel
implements CommandEncoder, Buildable
The chat window component. Displays text messages and accepts input. Also acts as a CommandEncoder, encoding/decoding commands that display message in the text area
See Also:
Serialized Form
  • Field Details

  • Constructor Details

    • Chatter

      public Chatter()
  • Method Details

    • getAnonymousUserName

      public static String getAnonymousUserName()
    • setChatterVisible

      protected void setChatterVisible​(boolean vis)
      Because our Chatters make themselves visible in their constructor, providing a way for an overriding class to "turn this chatter off" is friendlier than What Went Before.
      Parameters:
      vis - - whether this chatter should be visible
    • formatChat

      protected String formatChat​(String text)
    • getInputField

      public JTextField getInputField()
    • getChatStyle

      protected String getChatStyle​(String s)
      Styles a chat message based on the player who sent it. Presently just distinguishes a chat message "from me" from a chat message "from anyone else". To make the player colors easy to override in a custom class (my modules have logic to assign individual player colors -- beyond the scope of the present effort but a perhaps a fun future addition)
      Parameters:
      s - - chat message from a player
      Returns:
      - an entry in our CSS style sheet to use for this chat message
    • consoleHook

      public boolean consoleHook​(String s, String style, boolean html_allowed)
      A hook for inserting a console class that accepts commands
      Parameters:
      s - - chat message
      style - - current style name (contains information that might be useful)
      html_allowed - - flag if html_processing is enabled for this message (allows console to apply security considerations)
      Returns:
      true - if was accepted as a console command
    • show

      public void show​(String s)
      Display a message in the text area. Ensures we execute in the EDT
    • addStyle

      protected void addStyle​(String s, Font f, Color c, String font_weight, int size)
      Adds or updates a CSS stylesheet entry. Styles in the color, font type, and font size.
      Parameters:
      s - Style name
      f - Font to use
      c - Color for text
      font_weight - Bold? Italic?
      size - Font size
    • makeStyleSheet

      protected void makeStyleSheet​(Font f)
      Build ourselves a CSS stylesheet from our preference font/color settings.
      Parameters:
      f - - Font to use for this stylesheet
    • setFont

      public void setFont​(Font f)
      Set the Font used by the text area
      Overrides:
      setFont in class JComponent
    • build

      public void build​(Element e)
      Description copied from interface: Buildable
      Build the object
      Specified by:
      build in interface Buildable
      Parameters:
      e - the XML element containing the object data
    • getBuildElement

      public Element getBuildElement​(Document doc)
      Specified by:
      getBuildElement in interface Buildable
      Returns:
      an XML element from which this component can be built
    • addTo

      public void addTo​(Buildable b)
      Expects to be added to a GameModule. Adds itself to the controls window and registers itself as a CommandEncoder
      Specified by:
      addTo in interface Buildable
    • add

      public void add​(Buildable b)
      Description copied from interface: Buildable
      Adds a child component. Both this method and Buildable.addTo(VASSAL.build.Buildable) are invoked when adding a child to a parent
      Specified by:
      add in interface Buildable
    • decode

      public Command decode​(String s)
      Description copied from interface: CommandEncoder
      Translate a String into a Command
      Specified by:
      decode in interface CommandEncoder
    • encode

      public String encode​(Command c)
      Description copied from interface: CommandEncoder
      Translate a Command into a String
      Specified by:
      encode in interface CommandEncoder
    • send

      public void send​(String msg)
      Displays the message, Also logs and sends to the server a Command that displays this message.
    • warning

      public static void warning​(String msg)
      Warning message method -- same as send, but accepts messages from static methods. For reporting soft-fail problems in modules.
    • keyCommand

      public void keyCommand​(KeyStroke e)
      Classes other than the Chatter itself may forward KeyEvents to the Chatter by using this method
    • main

      public static void main​(String[] args)
    • setHandle

      @Deprecated(since="2020-08-06", forRemoval=true) public void setHandle​(String s)
      Deprecated, for removal: This API element is subject to removal in a future version.
      No Replacement
    • getHandle

      @Deprecated(since="2020-08-06", forRemoval=true) public String getHandle()
      Deprecated, for removal: This API element is subject to removal in a future version.