|
16 | 16 | * @modemail contact@achinthagunasekara.com |
17 | 17 | * |
18 | 18 | * @modifiedby Marcus Redgrave-Close |
19 | | - * @modemail marcusrc1@hotmail.co.uk |
| 19 | + * @modemail marcusrc1@hotmail.co.uk |
20 | 20 | */ |
21 | 21 |
|
22 | 22 | package simplejavatexteditor; |
|
37 | 37 | import javax.swing.text.DefaultEditorKit; |
38 | 38 |
|
39 | 39 | public class UI extends JFrame implements ActionListener { |
| 40 | + |
40 | 41 | private static final long serialVersionUID = 1L; |
41 | 42 | private final Container container; |
42 | 43 | private final JTextArea textArea; |
43 | 44 | private final JMenuBar menuBar; |
44 | 45 | private final JMenu menuFile, menuEdit, menuFind, menuAbout; |
45 | 46 | private final JMenuItem newFile, openFile, saveFile, close, cut, copy, paste, clearFile, selectAll, quickFind, |
46 | | - aboutMe, aboutSoftware, wordWrap; |
| 47 | + aboutMe, aboutSoftware, wordWrap; |
47 | 48 | private final JToolBar mainToolbar; |
48 | 49 | JButton newButton, openButton, saveButton, clearButton, quickButton, aboutMeButton, aboutButton, closeButton, |
49 | | - spaceButton1, spaceButton2; |
| 50 | + spaceButton1, spaceButton2; |
50 | 51 | private final Action selectAllAction; |
51 | 52 |
|
52 | 53 | // setup icons - File Menu |
@@ -126,7 +127,7 @@ public UI() { |
126 | 127 |
|
127 | 128 | // Set Actions: |
128 | 129 | selectAllAction = new SelectAllAction("Select All", clearIcon, "Select all text", new Integer(KeyEvent.VK_A), |
129 | | - textArea); |
| 130 | + textArea); |
130 | 131 |
|
131 | 132 | this.setJMenuBar(menuBar); |
132 | 133 |
|
@@ -194,15 +195,15 @@ public UI() { |
194 | 195 | */ |
195 | 196 | wordWrap.addActionListener(new ActionListener() |
196 | 197 | { |
197 | | - public void actionPerformed(ActionEvent ev) { |
198 | | - // If wrapping is false then after clicking on menuitem the word wrapping will be enabled |
199 | | - if(textArea.getLineWrap()==false) { |
200 | | - /* Setting word wrapping to true */ |
201 | | - textArea.setLineWrap(true); |
202 | | - } else { |
203 | | - // else if wrapping is true then after clicking on menuitem the word wrapping will be disabled |
204 | | - /* Setting word wrapping to false */ |
205 | | - textArea.setLineWrap(false); |
| 198 | + public void actionPerformed(ActionEvent ev) { |
| 199 | + // If wrapping is false then after clicking on menuitem the word wrapping will be enabled |
| 200 | + if(textArea.getLineWrap()==false) { |
| 201 | + /* Setting word wrapping to true */ |
| 202 | + textArea.setLineWrap(true); |
| 203 | + } else { |
| 204 | + // else if wrapping is true then after clicking on menuitem the word wrapping will be disabled |
| 205 | + /* Setting word wrapping to false */ |
| 206 | + textArea.setLineWrap(false); |
206 | 207 | } |
207 | 208 | } |
208 | 209 | }); |
@@ -306,8 +307,9 @@ protected JTextArea getEditor() { |
306 | 307 |
|
307 | 308 | public void actionPerformed (ActionEvent e) { |
308 | 309 | // If the source of the event was our "close" option |
309 | | - if (e.getSource() == close || e.getSource() == closeButton) |
| 310 | + if (e.getSource() == close || e.getSource() == closeButton) { |
310 | 311 | this.dispose(); // dispose all resources and close the application |
| 312 | + } |
311 | 313 |
|
312 | 314 | // If the source was the "new" file option |
313 | 315 | else if (e.getSource() == newFile || e.getSource() == newButton) { |
@@ -442,4 +444,5 @@ public void actionPerformed(ActionEvent e) { |
442 | 444 | textArea.selectAll(); |
443 | 445 | } |
444 | 446 | } |
| 447 | + |
445 | 448 | } |
0 commit comments