Class JTalkerMenuBar

  • All Implemented Interfaces:
    Initializable, ImageObserver, MenuContainer, Serializable, Accessible, MenuElement

    public class JTalkerMenuBar
    extends JMenuBar
    implements Initializable

    A menu bar for the JTalker application. This menu bar has five menus: file, edit, view, settings, and help. Each menu is separated by the functions of the software (file managment, editing of content, viewing of content, specific settings of content, and help with use of content). This is fairly standard, and as such standard keyboard shortcuts are used for each action. When you display the menu bar, it will look like this:

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

      • JTalkerMenuBar

        public JTalkerMenuBar​(JFrame frame,
                              ColoredTextPane coloredTextPane,
                              TextEntryPanel textEntryPanel,
                              CanvasPanel canvasPanel)
        Initializes the menu bar. The four components that are needed for the menu bar to work effectively are the JFrame, ColoredTextPane, TextEntryPanel, and the CanvasPanel. These things work in tandom to make sure each action described by this class is able to work.
        Parameters:
        frame - The frame of the application.
        coloredTextPane - The colored text pane of the application.
        textEntryPanel - The text entry panel of the application.
        canvasPanel - The canvas panel of the application.
    • Method Detail

      • createMenuItem

        protected static JMenuItem createMenuItem​(String name,
                                                  int accelerator,
                                                  int mask,
                                                  int mnemonic,
                                                  ActionListener action)
        Creates a JMenuItem to be added to the JTalkerMenuBar. This will create a menu item using the given name, the keystroke, mnemonic, and action associated with it. When it creates the menu item, it will add the keystroke to a map which can be used for later. If you wish to not add a keystroke, just make sure that the accelerator and/or mask variable is set to a number smaller than zero. However, the mnemonic is not optional.
        Parameters:
        name - The title of the menu item.
        accelerator - The accelerator of the menu item.
        mask - The mask of the menu item.
        mnemonic - The mnemonic of the menu item.
        action - The action to do when the menu item is pressed.
        Returns:
        The new menu item.
      • createButtonMenuItem

        protected static JRadioButtonMenuItem createButtonMenuItem​(String name,
                                                                   boolean enabled,
                                                                   int accelerator,
                                                                   int mask,
                                                                   int mnemonic,
                                                                   ActionListener action)
        Creates a JRadioButtonMenuItem to be added to the JTalkerMenuBar. This will create a menu item using the given name, whether it is enabled, the keystroke, mnemonic, and action associated with it. When it creates the menu item, it will add the keystroke to a map which can be used for later. If you wish to not add a keystroke, just make sure that the accelerator and/or mask variable is set to a number smaller than zero. However, the mnemonic is not optional.
        Parameters:
        name - The title of the menu item.
        enabled - Whether the radio button is on.
        accelerator - The accelerator of the menu item.
        mask - The mask of the menu item.
        mnemonic - The mnemonic of the menu item.
        action - The action to do when the menu item is pressed.
        Returns:
        The new menu item.
      • init

        public void init()
        Initializes each menu within the menu bar (file, edit, view, settings, and help).
        Specified by:
        init in interface Initializable
      • saveChat

        public void saveChat()
        Saves the chat to a file specified by the user. This will open up a file chooser, in which the user will select and confirm the saving of the file. This will save the escape codes found in the chat, even if the color mode for the chat is disabled.
      • saveCanvas

        public void saveCanvas()
        Saves the canvas as a PNG. This will open a file chooser in which the user can navigate to and save a png file that is described by the canvas object. It does so by creating a BufferedImage, painting the graphics to that image, and then writing that image using ImageIO.
        See Also:
        ImageIO
      • printChat

        public void printChat()
        Sends the chat to the printer service. This will print the colored text pane on a physical peice of paper (or to a file), exactly how the colored text pane determines it.
        See Also:
        ColoredTextPane.print(Graphics, PageFormat, int)
      • systemCopy

        public void systemCopy()
        A Java wrapper method for the system's "Copy" action.
      • systemCut

        public void systemCut()
        A Java wrapper method for the system's "Cut" action. This will not cut anything except for the text entry panel's JTextField.
      • systemPaste

        public void systemPaste()
        A Java wrapper method for the system's "Paste" action. This will automatically (and only) paste to the text entry panel's JTextField. This will not disable the normal paste; this will only work when this method is called (via a menu item for example).
      • selectColoredTextPane

        public void selectColoredTextPane()
        Select all of the colored text pane's text. This is a wrapper method for this method; however, it will also ensure that the selection can be seen after by requesting focus to the window manager.
      • openKeyboardShortcuts

        public void openKeyboardShortcuts()
        Opens a JOptionPane that displays the current keyboard shortcuts.
        See Also:
        SHORTCUTS
      • openConnection

        public void openConnection()
        Opens a connection to a remote server.
      • closeConnection

        public void closeConnection()
        Closes the connection to the remove server.