/* has the ability to copy, cut, paste & select all text in the JTextArea */
class Notepad {
private JMenuItem cuT, copY, pastE;
private JButton cutButton, copyButton, pasteButton;
Notepad() {
ediT.add( cuT = new JMenuItem( "Cut", new ImageIcon( this.getClass().getResource( "images/cut.gif" ) ) ) );
ediT.add( copY = new JMenuItem( "Copy", new ImageIcon( this.getClass().getResource( "images/copy.gif" ) ) ) );
ediT.add( pastE= new JMenuItem( "Paste",new ImageIcon( this.getClass().getResource( "images/paste.gif" ) ) ) );
cuT.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_X, ActionEvent.CTRL_MASK ) );
copY.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_C, ActionEvent.CTRL_MASK ) );
pastE.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_V, ActionEvent.CTRL_MASK ) );
toolBar.add( cutButton = new JButton( new ImageIcon( this.getClass().getResource( "images/cut.gif" ) ) ) );
toolBar.add( copyButton = new JButton( new ImageIcon( this.getClass().getResource( "images/copy.gif" ) ) ) );
toolBar.add( pasteButton = new JButton( new ImageIcon( this.getClass().getResource( "images/paste.gif" ) ) ) );
toolBar.addSeparator();
cutButton.setToolTipText( "Cut" );
copyButton.setToolTipText( "Copy" );
pasteButton.setToolTipText( "Paste" );
cuT.addActionListener( new ActionListener() {
public void actionPerformed( ActionEvent ae ) {
actions.cuT();
}
} );
copY.addActionListener( new ActionListener() {
public void actionPerformed( ActionEvent ae ) {
actions.copY();
}
} );
pastE.addActionListener( new ActionListener() {
public void actionPerformed( ActionEvent ae ) {
actions.pastE();
}
} );
cutButton.addActionListener( new ActionListener() {
public void actionPerformed( ActionEvent ae ) {
actions.cuT();
}
} );
copyButton.addActionListener( new ActionListener() {
public void actionPerformed( ActionEvent ae ) {
actions.copY();
}
} );
pasteButton.addActionListener( new ActionListener() {
public void actionPerformed( ActionEvent ae ) {
actions.pastE();
}
} );
}
}