When I click on "new" the text in the textarea is suppose to be cleared but nothing is happening
import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.util.Scanner; import java.io.*; public class MemoPad extends JFrame implements ActionListener { private TextArea textArea = new TextArea("", 0, 0, TextArea.SCROLLBARS_VERTICAL_ONLY); private MenuBar menuBar = new MenuBar(); private Menu file = new Menu(); private MenuItem openFile = new MenuItem(); private MenuItem newFile = new MenuItem(); private MenuItem saveFile = new MenuItem(); private MenuItem close = new MenuItem(); public MemoPad() { this.setSize(600, 300); this.setTitle("Memo Pad"); setDefaultCloseOperation(EXIT_ON_CLOSE); this.getContentPane().setLayout(new BorderLayout()); this.getContentPane().add(textArea); this.setMenuBar(this.menuBar); this.menuBar.add(this.file); this.file.setLabel("File"); this.newFile.setLabel("New"); this.file.add(this.newFile); this.openFile.setLabel("Open"); this.file.add(this.openFile); this.saveFile.setLabel("Save"); this.file.add(this.saveFile); this.file.addSeparator(); this.close.setLabel("Exit"); this.close.addActionListener(this); this.file.add(this.close); } public void actionPerformed(ActionEvent e) { if (e.getSource() == this.close) { this.dispose(); } else if (e.getSource() == this.openFile) { JFileChooser open = new JFileChooser(); int option = open.showOpenDialog(this); if (option == JFileChooser.APPROVE_OPTION) { this.textArea.setText(""); try { Scanner scan = new Scanner(new FileReader(open.getSelectedFile().getPath())); while (scan.hasNext()) { this.textArea.append(scan.nextLine() + "\n"); } } catch (Exception ex) { System.out.println(ex.getMessage()); } } } if (e.getSource() == this.newFile) { this.textArea.setText(""); } else if (e.getSource() == this.saveFile) { JFileChooser save = new JFileChooser(); int option = save.showSaveDialog(this); if (option == JFileChooser.APPROVE_OPTION) { try { BufferedWriter out = new BufferedWriter(new FileWriter(save.getSelectedFile().getPath())); out.write(this.textArea.getText()); out.close(); } catch (Exception ex) { System.out.println(ex.getMessage()); } } } } }