Example usage for java.awt.event KeyEvent VK_Y

List of usage examples for java.awt.event KeyEvent VK_Y

Introduction

In this page you can find the example usage for java.awt.event KeyEvent VK_Y.

Prototype

int VK_Y

To view the source code for java.awt.event KeyEvent VK_Y.

Click Source Link

Document

Constant for the "Y" key.

Usage

From source file:Main.java

public static void main(String[] args) throws Exception {
    Robot robot = new Robot();

    robot.delay(3000);/* w w w  .  j  a  va2  s .co  m*/

    robot.keyPress(KeyEvent.VK_Q);
    robot.keyPress(KeyEvent.VK_W);
    robot.keyPress(KeyEvent.VK_E);
    robot.keyPress(KeyEvent.VK_R);
    robot.keyPress(KeyEvent.VK_T);
    robot.keyPress(KeyEvent.VK_Y);
}

From source file:ColorAction.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setTitle("SeparateGUITest");
    frame.setSize(300, 200);//from  w  w w .j ava 2  s .  com
    frame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });

    JPanel panel = new JPanel();

    Action blueAction = new ColorAction("Blue", new ImageIcon("blue-ball.gif"), Color.blue, panel);
    Action yellowAction = new ColorAction("Yellow", new ImageIcon("yellow-ball.gif"), Color.yellow, panel);
    Action redAction = new ColorAction("Red", new ImageIcon("red-ball.gif"), Color.red, panel);

    panel.add(new JButton(yellowAction));
    panel.add(new JButton(blueAction));
    panel.add(new JButton(redAction));

    panel.registerKeyboardAction(yellowAction, KeyStroke.getKeyStroke(KeyEvent.VK_Y, 0),
            JComponent.WHEN_IN_FOCUSED_WINDOW);
    panel.registerKeyboardAction(blueAction, KeyStroke.getKeyStroke(KeyEvent.VK_B, 0),
            JComponent.WHEN_IN_FOCUSED_WINDOW);
    panel.registerKeyboardAction(redAction, KeyStroke.getKeyStroke(KeyEvent.VK_R, 0),
            JComponent.WHEN_IN_FOCUSED_WINDOW);

    Container contentPane = frame.getContentPane();
    contentPane.add(panel);

    JMenu m = new JMenu("Color");
    m.add(yellowAction);
    m.add(blueAction);
    m.add(redAction);
    JMenuBar mbar = new JMenuBar();
    mbar.add(m);
    frame.setJMenuBar(mbar);

    frame.show();
}

From source file:Main.java

@SuppressWarnings("serial")
public static void installUndoManager(JTextComponent textComponent, final UndoManager undoManager) {

    Document doc = textComponent.getDocument();
    doc.addUndoableEditListener(new UndoableEditListener() {
        public void undoableEditHappened(UndoableEditEvent e) {
            undoManager.addEdit(e.getEdit());
        }/*w  w w.jav a  2 s .  c  o m*/
    });

    ActionMap am = textComponent.getActionMap();
    InputMap im = textComponent.getInputMap();
    am.put("undo", new AbstractAction("undo") {
        @Override
        public void actionPerformed(ActionEvent e) {
            undoManager.undo();
        }

        @Override
        public boolean isEnabled() {
            return undoManager.canUndo();
        }
    });
    im.put(KeyStroke.getKeyStroke(KeyEvent.VK_Z, getMenuShortcutKeyMask()), "undo");

    am.put("redo", new AbstractAction("redo") {
        @Override
        public void actionPerformed(ActionEvent e) {
            undoManager.redo();
        }

        @Override
        public boolean isEnabled() {
            return undoManager.canRedo();
        }
    });
    im.put(KeyStroke.getKeyStroke(KeyEvent.VK_Y, getMenuShortcutKeyMask()), "redo");
}

From source file:UndoableTextArea.java

public void keyPressed(KeyEvent e) {
    if ((e.getKeyCode() == KeyEvent.VK_Z) && (e.isControlDown())) {
        try {//  w  w w  . j a  v a  2s.c o m
            m_undoManager.undo();
        } catch (CannotUndoException cue) {
            Toolkit.getDefaultToolkit().beep();
        }
    }

    if ((e.getKeyCode() == KeyEvent.VK_Y) && (e.isControlDown())) {
        try {
            m_undoManager.redo();
        } catch (CannotRedoException cue) {
            Toolkit.getDefaultToolkit().beep();
        }
    }
}

From source file:Main.java

/**
 * Returns the mnemonic integer./*from   ww w.  j a  v  a  2  s  .  com*/
 * 
 * @param c The character (uppercase)
 * @return The mnemonic.
 */
@SuppressWarnings("incomplete-switch")
private static int setMnemonicsGet(char c) {
    int mnemonic = 0;
    switch (Character.toUpperCase(c)) {
    case '0':
        mnemonic = KeyEvent.VK_0;
        break;
    case '1':
        mnemonic = KeyEvent.VK_1;
        break;
    case '2':
        mnemonic = KeyEvent.VK_2;
        break;
    case '3':
        mnemonic = KeyEvent.VK_3;
        break;
    case '4':
        mnemonic = KeyEvent.VK_4;
        break;
    case '5':
        mnemonic = KeyEvent.VK_5;
        break;
    case '6':
        mnemonic = KeyEvent.VK_6;
        break;
    case '7':
        mnemonic = KeyEvent.VK_7;
        break;
    case '8':
        mnemonic = KeyEvent.VK_8;
        break;
    case '9':
        mnemonic = KeyEvent.VK_9;
        break;
    case 'A':
        mnemonic = KeyEvent.VK_A;
        break;
    case 'B':
        mnemonic = KeyEvent.VK_B;
        break;
    case 'C':
        mnemonic = KeyEvent.VK_C;
        break;
    case 'D':
        mnemonic = KeyEvent.VK_D;
        break;
    case 'E':
        mnemonic = KeyEvent.VK_E;
        break;
    case 'F':
        mnemonic = KeyEvent.VK_F;
        break;
    case 'G':
        mnemonic = KeyEvent.VK_G;
        break;
    case 'H':
        mnemonic = KeyEvent.VK_H;
        break;
    case 'I':
        mnemonic = KeyEvent.VK_I;
        break;
    case 'J':
        mnemonic = KeyEvent.VK_J;
        break;
    case 'K':
        mnemonic = KeyEvent.VK_K;
        break;
    case 'L':
        mnemonic = KeyEvent.VK_L;
        break;
    case 'M':
        mnemonic = KeyEvent.VK_M;
        break;
    case 'N':
        mnemonic = KeyEvent.VK_N;
        break;
    case 'O':
        mnemonic = KeyEvent.VK_O;
        break;
    case 'P':
        mnemonic = KeyEvent.VK_P;
        break;
    case 'Q':
        mnemonic = KeyEvent.VK_Q;
        break;
    case 'R':
        mnemonic = KeyEvent.VK_R;
        break;
    case 'S':
        mnemonic = KeyEvent.VK_S;
        break;
    case 'T':
        mnemonic = KeyEvent.VK_T;
        break;
    case 'U':
        mnemonic = KeyEvent.VK_U;
        break;
    case 'V':
        mnemonic = KeyEvent.VK_V;
        break;
    case 'W':
        mnemonic = KeyEvent.VK_W;
        break;
    case 'X':
        mnemonic = KeyEvent.VK_X;
        break;
    case 'Y':
        mnemonic = KeyEvent.VK_Y;
        break;
    case 'Z':
        mnemonic = KeyEvent.VK_Z;
        break;
    }
    return mnemonic;
}

From source file:UndoExample5.java

public UndoExample5() {
    super("Undo/Redo Example 5");

    pane = new JTextPane();
    pane.setEditable(true); // Editable
    getContentPane().add(new JScrollPane(pane), BorderLayout.CENTER);

    // Add a menu bar
    menuBar = new JMenuBar();
    setJMenuBar(menuBar);/*from   www. j  av a  2s  .co  m*/

    // Populate the menu bar
    createMenuBar();

    // Create the undo manager and actions
    MonitorableUndoManager manager = new MonitorableUndoManager();
    pane.getDocument().addUndoableEditListener(manager);

    Action undoAction = new UndoAction(manager);
    Action redoAction = new RedoAction(manager);

    // Add the actions to buttons
    JPanel panel = new JPanel();
    final JButton undoButton = new JButton("Undo");
    final JButton redoButton = new JButton("Redo");
    undoButton.addActionListener(undoAction);
    redoButton.addActionListener(redoAction);

    undoButton.setEnabled(false);
    redoButton.setEnabled(false);
    panel.add(undoButton);
    panel.add(redoButton);
    getContentPane().add(panel, BorderLayout.SOUTH);

    // Assign the actions to keys
    pane.registerKeyboardAction(undoAction, KeyStroke.getKeyStroke(KeyEvent.VK_Z, InputEvent.CTRL_MASK),
            JComponent.WHEN_FOCUSED);
    pane.registerKeyboardAction(redoAction, KeyStroke.getKeyStroke(KeyEvent.VK_Y, InputEvent.CTRL_MASK),
            JComponent.WHEN_FOCUSED);

    // Handle events from the MonitorableUndoManager
    manager.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent evt) {
            MonitorableUndoManager m = (MonitorableUndoManager) evt.getSource();
            boolean canUndo = m.canUndo();
            boolean canRedo = m.canRedo();

            undoButton.setEnabled(canUndo);
            redoButton.setEnabled(canRedo);

            undoButton.setToolTipText(canUndo ? m.getUndoPresentationName() : null);
            redoButton.setToolTipText(canRedo ? m.getRedoPresentationName() : null);
        }
    });
}

From source file:UndoExample3.java

public UndoExample3() {
    super("Undo/Redo Example 3");

    DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("root");
    DefaultMutableTreeNode node = new DefaultMutableTreeNode("Apollo 8");
    rootNode.add(node);/*from   ww w  . j  av a 2  s . c  o  m*/
    node.add(new DefaultMutableTreeNode("Borman"));
    node.add(new DefaultMutableTreeNode("Lovell"));
    node.add(new DefaultMutableTreeNode("Anders"));

    node = new DefaultMutableTreeNode("Apollo 11");
    rootNode.add(node);
    node.add(new DefaultMutableTreeNode("Armstrong"));
    node.add(new DefaultMutableTreeNode("Aldrin"));
    node.add(new DefaultMutableTreeNode("Collins"));

    node = new DefaultMutableTreeNode("Apollo 12");
    rootNode.add(node);
    node.add(new DefaultMutableTreeNode("Conrad"));
    node.add(new DefaultMutableTreeNode("Gordon"));
    node.add(new DefaultMutableTreeNode("Bean"));

    UndoableTree tree = new UndoableTree(rootNode);

    getContentPane().add(new JScrollPane(tree), BorderLayout.CENTER);

    // Create the undo manager and actions
    UndoManager manager = new UndoManager();
    tree.addUndoableEditListener(manager);

    Action undoAction = new UndoAction(manager);
    Action redoAction = new RedoAction(manager);

    // Add the actions to buttons
    JPanel panel = new JPanel();
    JButton undoButton = new JButton("Undo");
    JButton redoButton = new JButton("Redo");
    undoButton.addActionListener(undoAction);
    redoButton.addActionListener(redoAction);
    panel.add(undoButton);
    panel.add(redoButton);
    getContentPane().add(panel, BorderLayout.SOUTH);

    // Assign the actions to keys
    ((JComponent) getContentPane()).registerKeyboardAction(undoAction,
            KeyStroke.getKeyStroke(KeyEvent.VK_Z, InputEvent.CTRL_MASK), JComponent.WHEN_IN_FOCUSED_WINDOW);
    ((JComponent) getContentPane()).registerKeyboardAction(redoAction,
            KeyStroke.getKeyStroke(KeyEvent.VK_Y, InputEvent.CTRL_MASK), JComponent.WHEN_IN_FOCUSED_WINDOW);
}

From source file:UndoExample4.java

public UndoExample4() {
    super("Undo/Redo Example 4");

    DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("root");
    DefaultMutableTreeNode node = new DefaultMutableTreeNode("Apollo 8");
    rootNode.add(node);//w w  w .  j a  v a 2  s .c  om
    node.add(new DefaultMutableTreeNode("Borman"));
    node.add(new DefaultMutableTreeNode("Lovell"));
    node.add(new DefaultMutableTreeNode("Anders"));

    node = new DefaultMutableTreeNode("Apollo 11");
    rootNode.add(node);
    node.add(new DefaultMutableTreeNode("Armstrong"));
    node.add(new DefaultMutableTreeNode("Aldrin"));
    node.add(new DefaultMutableTreeNode("Collins"));

    node = new DefaultMutableTreeNode("Apollo 12");
    rootNode.add(node);
    node.add(new DefaultMutableTreeNode("Conrad"));
    node.add(new DefaultMutableTreeNode("Gordon"));
    node.add(new DefaultMutableTreeNode("Bean"));

    UndoableTree2 tree = new UndoableTree2(rootNode);

    getContentPane().add(new JScrollPane(tree), BorderLayout.CENTER);

    // Create the undo manager and actions
    UndoManager manager = new UndoManager();
    tree.addUndoableEditListener(manager);

    Action undoAction = new UndoAction(manager);
    Action redoAction = new RedoAction(manager);

    // Add the actions to buttons
    JPanel panel = new JPanel();
    JButton undoButton = new JButton("Undo");
    JButton redoButton = new JButton("Redo");
    undoButton.addActionListener(undoAction);
    redoButton.addActionListener(redoAction);
    panel.add(undoButton);
    panel.add(redoButton);
    getContentPane().add(panel, BorderLayout.SOUTH);

    // Assign the actions to keys
    ((JComponent) getContentPane()).registerKeyboardAction(undoAction,
            KeyStroke.getKeyStroke(KeyEvent.VK_Z, InputEvent.CTRL_MASK), JComponent.WHEN_IN_FOCUSED_WINDOW);
    ((JComponent) getContentPane()).registerKeyboardAction(redoAction,
            KeyStroke.getKeyStroke(KeyEvent.VK_Y, InputEvent.CTRL_MASK), JComponent.WHEN_IN_FOCUSED_WINDOW);
}

From source file:com.evanbelcher.DrillBook.display.DBMenuBar.java

/**
 * Constructs DBMenuBar. Adds the menu and menuitems.
 *
 * @param graphicsRunner the JFrame that created this
 * @param desktop        the DBDesktopPane in the JFrame
 *///ww  w .  j  av a2  s. c om
public DBMenuBar(GraphicsRunner graphicsRunner, DBDesktopPane desktop) {
    super();

    gr = graphicsRunner;
    this.desktop = desktop;

    //Set up the menu
    JMenu menu = new JMenu("File");
    add(menu);

    //Set up the menu items.
    JMenuItem menuItem = new JMenuItem("New");
    menuItem.setMnemonic(KeyEvent.VK_N);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.CTRL_DOWN_MASK));
    menuItem.setActionCommand("new");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    menuItem = new JMenuItem("Open");
    menuItem.setMnemonic(KeyEvent.VK_O);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_DOWN_MASK));
    menuItem.setActionCommand("open");
    menuItem.addActionListener(this);
    menuItem.setLayout(new MigLayout());
    menu.add(menuItem);

    menuItem = new JMenuItem("Save");
    menuItem.setMnemonic(KeyEvent.VK_S);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK));
    menuItem.setActionCommand("save");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    menuItem = new JMenuItem("Save As");
    menuItem.setActionCommand("saveas");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    menuItem = new JMenuItem("Print    Current Page");
    menuItem.setMnemonic(KeyEvent.VK_P);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, InputEvent.CTRL_DOWN_MASK));
    menuItem.setActionCommand("printpage");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    menuItem = new JMenuItem("Print Show");
    menuItem.setActionCommand("printshow");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    menuItem = new JMenuItem("Print Dot Sheets");
    menuItem.setActionCommand("printdotsheets");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    menuItem = new JMenuItem("Quit");
    menuItem.setMnemonic(KeyEvent.VK_Q);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, InputEvent.CTRL_DOWN_MASK));
    menuItem.setActionCommand("quit");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    menu = new JMenu("Edit");
    add(menu);

    menuItem = new JMenuItem("Undo");
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Z, InputEvent.CTRL_DOWN_MASK));
    menuItem.setActionCommand("undo");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    menuItem = new JMenuItem("Redo");
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Y, InputEvent.CTRL_DOWN_MASK));
    menuItem.setActionCommand("redo");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    menu = new JMenu("Settings");
    add(menu);

    menuItem = new JMenuItem("Toggle Gridlines");
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_G, InputEvent.CTRL_DOWN_MASK));
    menuItem.setActionCommand("togglegrid");
    menuItem.addActionListener(this);
    menuItem.setForeground(Main.getState().getSettings().shouldShowGrid() ? Color.BLACK : Color.RED);
    menu.add(menuItem);

    menuItem = new JMenuItem("Toggle Dot Names");
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D, InputEvent.CTRL_DOWN_MASK));
    menuItem.setActionCommand("togglenames");
    menuItem.addActionListener(this);
    menuItem.setForeground(Main.getState().getSettings().shouldShowNames() ? Color.BLACK : Color.RED);
    menu.add(menuItem);

    menuItem = new JMenuItem("Toggle Text Box");
    menuItem.setActionCommand("toggletext");
    menuItem.addActionListener(this);
    menuItem.setForeground(Main.getState().getSettings().shouldShowText() ? Color.BLACK : Color.RED);
    menu.add(menuItem);

    menuItem = new JMenuItem("Color Code Dots by Instrument");
    menuItem.setActionCommand("colordots");
    menuItem.addActionListener(this);
    menuItem.setForeground(Main.getState().getSettings().shouldColorDots() ? Color.BLACK : Color.RED);
    menu.add(menuItem);

    menuItem = new JMenuItem();
    menuItem.setText(Main.getState().getSettings().useCollegeHashes() ? "Change to High School Hashes"
            : "Change to College Hashes");
    menuItem.setActionCommand("changehash");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    menuItem = new JMenuItem("Change Font Size");
    menuItem.setActionCommand("fontsize");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    //add(Box.createHorizontalStrut(menu.getPreferredSize().width));

    //add these to the menubar itself
    menuItem = new JMenuItem("Play");
    menuItem.setMaximumSize(new Dimension(menuItem.getPreferredSize().width, Integer.MAX_VALUE));
    menuItem.setActionCommand("play");
    menuItem.addActionListener(this);
    add(menuItem);

    add(Box.createHorizontalGlue());

    menu = new JMenu("Help");
    add(menu);

    menuItem = new JMenuItem("Help");
    menuItem.setActionCommand("help");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    menuItem = new JMenuItem("About");
    menuItem.setActionCommand("about");
    menuItem.addActionListener(this);
    menu.add(menuItem);
}

From source file:com.prodigy4440.view.MainJFrame.java

public final void initComponents() {

    List<Image> icons = new LinkedList<>();
    icons.add(new ImageIcon(getClass().getResource("/com/prodigy4440/ited16x16.png")).getImage());
    icons.add(new ImageIcon(getClass().getResource("/com/prodigy4440/ited32x32.png")).getImage());
    icons.add(new ImageIcon(getClass().getResource("/com/prodigy4440/ited48x48.png")).getImage());
    icons.add(new ImageIcon(getClass().getResource("/com/prodigy4440/ited72x72.png")).getImage());

    this.setIconImages(icons);

    ActionHandler actionHandler = new ActionHandler(this);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    this.setSize(620, 520);
    this.setLocationRelativeTo(null);
    this.setTitle("Untitled Document- IgboTextEditor");
    southJPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    SoftBevelBorder sbb = new SoftBevelBorder(SoftBevelBorder.LOWERED);
    southJPanel.setBorder(sbb);//from www  .  ja  va 2  s  . c o m
    menuBar = new JMenuBar();

    fileJMenu = new JMenu("File");
    fileJMenu.setMnemonic('F');
    editJMenu = new JMenu("Edit");
    editJMenu.setMnemonic('E');
    formatJMenu = new JMenu("Format");
    formatJMenu.setMnemonic('A');
    viewJMenu = new JMenu("View");
    viewJMenu.setMnemonic('V');
    helpJMenu = new JMenu("Help");
    helpJMenu.setMnemonic('H');

    newDocumentJMenuItem = new JMenuItem("New");
    newDocumentJMenuItem.addActionListener(actionHandler);
    newDocumentJMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, Event.CTRL_MASK));
    openJMenuItem = new JMenuItem("Open");
    openJMenuItem.addActionListener(actionHandler);
    openJMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, Event.CTRL_MASK));
    saveJMenuItem = new JMenuItem("Save");
    saveJMenuItem.addActionListener(actionHandler);
    saveJMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, Event.CTRL_MASK));
    printJMenuItem = new JMenuItem("Print");
    printJMenuItem.addActionListener(actionHandler);
    printJMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, Event.CTRL_MASK));
    exitJMenuItem = new JMenuItem("Exit");
    exitJMenuItem.addActionListener(actionHandler);

    undoJMenuItem = new JMenuItem("Undo");
    undoJMenuItem.addActionListener(actionHandler);
    undoJMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Z, Event.CTRL_MASK));
    redoJMenuItem = new JMenuItem("Redo");
    redoJMenuItem.addActionListener(actionHandler);
    redoJMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Y, Event.CTRL_MASK));
    copyJMenuItem = new JMenuItem("Copy");
    copyJMenuItem.addActionListener(actionHandler);
    copyJMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, Event.CTRL_MASK));
    cutJMenuItem = new JMenuItem("Cut");
    cutJMenuItem.addActionListener(actionHandler);
    cutJMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, Event.CTRL_MASK));
    pasteJMenuItem = new JMenuItem("Paste");
    pasteJMenuItem.addActionListener(actionHandler);
    pasteJMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, Event.CTRL_MASK));
    deleteJMenuItem = new JMenuItem("Delete");
    deleteJMenuItem.addActionListener(actionHandler);
    deleteJMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D, Event.CTRL_MASK));
    selectAllJMenuItem = new JMenuItem("Select All");
    selectAllJMenuItem.addActionListener(actionHandler);
    selectAllJMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, Event.CTRL_MASK));
    findJMenuItem = new JMenuItem("Find");
    findJMenuItem.addActionListener(actionHandler);
    findJMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F, Event.CTRL_MASK));
    replaceJMenuItem = new JMenuItem("Replace");
    replaceJMenuItem.addActionListener(actionHandler);
    replaceJMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, Event.CTRL_MASK));

    wordWrapJCheckBoxMenuItem = new JCheckBoxMenuItem("Word Wrap");
    wordWrapJCheckBoxMenuItem.addActionListener(actionHandler);
    wordWrapJCheckBoxMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_W, Event.CTRL_MASK));
    fontJMenuItem = new JMenuItem("Font");
    fontJMenuItem.addActionListener(actionHandler);
    colorJMenuItem = new JMenuItem("Color");
    colorJMenuItem.addActionListener(actionHandler);

    statusBarJCheckBoxMenuItem = new JCheckBoxMenuItem("Status Bar");
    statusBarJCheckBoxMenuItem.addActionListener(actionHandler);
    statusBarJCheckBoxMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, Event.ALT_MASK));

    helpJMenuItem = new JMenuItem("Help");
    helpJMenuItem.addActionListener(actionHandler);
    helpJMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_M, Event.CTRL_MASK));
    aboutJMenuItem = new JMenuItem("About");
    aboutJMenuItem.addActionListener(actionHandler);

    statusJLabel = new JLabel("Status:");

    //Main text area setup
    textArea = new JTextArea();
    undoManager = new UndoManager();
    wordSearcher = new WordSearcher(textArea);
    textArea.setBorder(BorderFactory.createMatteBorder(4, 4, 4, 4, Color.WHITE));
    document = textArea.getDocument();
    document.addUndoableEditListener(new UndoableEditListener() {
        @Override
        public void undoableEditHappened(UndoableEditEvent e) {
            undoManager.addEdit(e.getEdit());
        }
    });

    font = new Font("Tahoma", Font.PLAIN, 16);
    textArea.setFont(font);
    color = Color.BLUE;
    textArea.setForeground(color);

    undoManager = new UndoManager();

    fileJMenu.add(newDocumentJMenuItem);
    fileJMenu.addSeparator();
    fileJMenu.add(openJMenuItem);
    fileJMenu.add(saveJMenuItem);
    fileJMenu.addSeparator();
    fileJMenu.add(printJMenuItem);
    fileJMenu.addSeparator();
    fileJMenu.add(exitJMenuItem);

    editJMenu.add(undoJMenuItem);
    editJMenu.add(redoJMenuItem);
    editJMenu.addSeparator();
    editJMenu.add(copyJMenuItem);
    editJMenu.add(cutJMenuItem);
    editJMenu.add(pasteJMenuItem);
    editJMenu.addSeparator();
    editJMenu.add(deleteJMenuItem);
    editJMenu.add(selectAllJMenuItem);
    editJMenu.addSeparator();
    editJMenu.add(findJMenuItem);
    editJMenu.add(replaceJMenuItem);

    formatJMenu.add(wordWrapJCheckBoxMenuItem);
    formatJMenu.add(fontJMenuItem);
    formatJMenu.add(colorJMenuItem);

    viewJMenu.add(statusBarJCheckBoxMenuItem);

    helpJMenu.add(helpJMenuItem);
    helpJMenu.add(aboutJMenuItem);

    menuBar.add(fileJMenu);
    menuBar.add(editJMenu);
    menuBar.add(formatJMenu);
    menuBar.add(viewJMenu);
    menuBar.add(helpJMenu);

    southJPanel.setVisible(false);
    southJPanel.add(statusJLabel);
    //JScrollPane setup
    JScrollPane scrollPane = new JScrollPane(textArea);
    scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    //setting uo the Jframe
    this.setJMenuBar(menuBar);
    this.add(scrollPane, BorderLayout.CENTER);
    this.add(southJPanel, BorderLayout.SOUTH);
    textArea.addMouseListener(new MouseInputListener() {

        @Override
        public void mouseClicked(MouseEvent e) {
            Highlighter h = textArea.getHighlighter();
            h.removeAllHighlights();
        }

        @Override
        public void mousePressed(MouseEvent e) {
            Highlighter h = textArea.getHighlighter();
            h.removeAllHighlights();
        }

        @Override
        public void mouseReleased(MouseEvent e) {
        }

        @Override
        public void mouseEntered(MouseEvent e) {
        }

        @Override
        public void mouseExited(MouseEvent e) {
        }

        @Override
        public void mouseDragged(MouseEvent e) {
        }

        @Override
        public void mouseMoved(MouseEvent e) {
        }
    });

    textArea.addKeyListener(new IgboKeyListener(textArea));

}