package com.dw.notepad2;

import java.awt.BorderLayout;
import java.awt.Color;
import java.io.*;
import java.util.*;


import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;

public class Notepad2 extends JPanel {
	
	protected static Properties properties;
	private static ResourceBundle resources;
	private final static String EXIT_AFTER_PAINT = "-exit";
	private static boolean exitAfterFirstPaint;

	static {
		try {
			properties = new Properties();
			properties.load(Notepad2.class.getClassLoader().getResourceAsStream("resources/Notepad.properties"));
			resources = ResourceBundle.getBundle("resources.Notepad", Locale.getDefault());
		} catch (MissingResourceException | IOException e) {
			System.err.println("resources/Notepad.properties " + "or resources/NotepadSystem.properties not found");
			System.exit(1);
		}
	}
	
	public static void main(String[] args) throws Exception {
		if (args.length > 0 && args[0].equals(EXIT_AFTER_PAINT)) {
			exitAfterFirstPaint = true;
		}
		SwingUtilities.invokeAndWait(new Runnable() {

			public void run()
			{
				JFrame frame = new JFrame();
				frame.setTitle(resources.getString("Title"));
				frame.setBackground(Color.lightGray);
				frame.getContentPane().setLayout(new BorderLayout());
				Notepad2 notepad = new Notepad2();
				frame.getContentPane().add("Center", notepad);
				/*frame.setJMenuBar(notepad.createMenubar());
				frame.addWindowListener(new AppCloser());*/
				frame.pack();
				frame.setSize(500, 600);
				frame.setVisible(true);
			}
		});
	}
}

@@ -76,16 +76,90 @@
 Color;%0D%0A
+import java.awt.event.WindowAdapter;%0D%0Aimport java.awt.event.WindowEvent;%0D%0A
 import j
@@ -169,16 +169,16 @@
 .io.*;%0D%0A
-
 import j
@@ -519,16 +519,451 @@
 tPaint;%0D
+%0A%09%0D%0A%09private static final String%5B%5D MENUBAR_KEYS = %7B %22file%22, %22edit%22, %22debug%22 %7D;%0D%0A%09private static final String%5B%5D TOOLBAR_KEYS = %7B %22new%22, %22open%22, %22save%22, %22-%22, %22cut%22, %22copy%22, %22paste%22 %7D;%0D%0A%09private static final String%5B%5D FILE_KEYS = %7B %22new%22, %22open%22, %22save%22, %22-%22, %22exit%22 %7D;%0D%0A%09private static final String%5B%5D EDIT_KEYS = %7B %22cut%22, %22copy%22, %22paste%22, %22-%22, %22undo%22, %22redo%22 %7D;%0D%0A%09private static final String%5B%5D DEBUG_KEYS = %7B %22dump%22, %22showElementTree%22 %7D;%0D
 %0A%0D%0A%09stat
@@ -1399,16 +1399,217 @@
 %0A%09%7D%0D%0A%09%0D%0A
+%09protected static final class AppCloser extends WindowAdapter %7B%0D%0A%0D%0A%09%09@Override%0D%0A%09%09public void windowClosing(WindowEvent e)%0D%0A%09%09%7B%0D%0A%09%09%09System.out.println(%22AppCloser!!!%22);%0D%0A%09%09%09System.exit(0);%0D%0A%09%09%7D%0D%0A%09%7D%0D%0A%09%0D%0A
 %09public 
@@ -2164,24 +2164,24 @@
 enubar());%0D%0A
-
 %09%09%09%09frame.ad
@@ -2217,16 +2217,63 @@
 ());*/%0D%0A
+%09%09%09%09frame.addWindowListener(new AppCloser());%0D%0A
 %09%09%09%09fram

add windows close listener