Class TextEntryPanel

  • All Implemented Interfaces:
    Initializable, KeyListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible

    public class TextEntryPanel
    extends JPanel
    implements Initializable, KeyListener

    A panel that allows entry and sending of text. This consists of two parts: entry and sending. Entry is simple: we use a JTextField to enter in text, and said text is cleared when the enter button is pressed. However, "sending" is more complicated. We have created an interface called TextPipe, in which we allow the sending of specific text. If we were to visualize how this panel "sends" text, it would be like a bunch of pipes branching out from a single entry point. This entry point would be stopped by the "send" button, and when it is pressed, the pipe is opened (and susequently shut). We allow the installation of new pipes via the addTextUpdater(TextPipe) method. When you display the panel, it will look like this:

    Since:
    JTalker 0.1.5
    Version:
    0.0.1
    Author:
    C. William Oswald
    See Also:
    TextPipe, Serialized Form
    • Field Detail

      • entryField

        protected JTextField entryField
        The text entry field of the panel. This allows the text to be entered, and when the class is initialized, its text will be sent along any TextPipe given to this panel (and then subsiquently cleared).
      • sendButton

        protected JButton sendButton
        The send buttong of the panel. This allows the text to actually be sent along the TextPipes provided by the TextUpdaters that are added to this button as ActionListeners.
    • Constructor Detail

      • TextEntryPanel

        public TextEntryPanel()
        Constructs a TextEntryPanel. Note that you still have to call the init method in order for anything to work.
    • Method Detail

      • init

        public void init()
        Initializes the entry panel by adding the components and making sure that the enter key also pushes the button. The sizes for the button as well as the height of the entry panel are defined in GUIConstants: width and height. The text within the text entry field is set to the default font.
        Specified by:
        init in interface Initializable
      • keyPressed

        public void keyPressed​(KeyEvent e)
        Invoked when a key has been pressed. When and enter is pressed, it will click the send button, therefore activating its action performers.
        Specified by:
        keyPressed in interface KeyListener
        Parameters:
        e - The key event (hopefully an enter).
      • keyReleased

        public void keyReleased​(KeyEvent e)
        Invoked when a key has been released. This is unimplemented.
        Specified by:
        keyReleased in interface KeyListener
        Parameters:
        e - The key event to ignore.
      • keyTyped

        public void keyTyped​(KeyEvent e)
        Invoked when a key has been typed. This is unimplemented.
        Specified by:
        keyTyped in interface KeyListener
        Parameters:
        e - the key event ot ignore.
      • requestFocus

        public void requestFocus()
        Requests that this TextEntryPanel gets the input focus. This will call the underlying JTextField's requestFocus method.
        Overrides:
        requestFocus in class JComponent
      • addTextUpdater

        public void addTextUpdater​(TextPipe pipe)
        Adds a TextUpdater to this TextEntryPanel.
        Parameters:
        pipe - The text pipe to make a TextUpdater out of.
      • getTextField

        public JTextField getTextField()
        Returns the JTextField that is used for text entry.
        Returns:
        The JTextField that is used for text entry.
      • getButton

        public JButton getButton()
        Returns the JButton that is used for sending text.
        Returns:
        The JButton that is used for sending text.