Skip to content

Commit

Permalink
Added New feature. Note: have not yet checked for save
Browse files Browse the repository at this point in the history
  • Loading branch information
fletchthefletch committed Aug 3, 2021
1 parent 5a4ddb5 commit 8550525
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 14 deletions.
11 changes: 0 additions & 11 deletions .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,5 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
14 changes: 13 additions & 1 deletion src/main/java/nz/ac/massey/cs/texteditor/Listener.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@

import java.awt.event.*;

import javax.swing.JFrame;

public class Listener implements ActionListener {

private TextEditor frame;
private JFrame jf;

public Listener(TextEditor frame) {
this.frame = frame;
this.jf = frame.getFrame();
}

public void actionPerformed(ActionEvent e) {
Expand All @@ -19,7 +23,15 @@ public void actionPerformed(ActionEvent e) {
// Unsaved --> Force user to save file

// Load a new file into the current window
break;
boolean saved = true;

if (!saved) {
// Force user to save this file
}
else {
// Create new file in the same window
new TextEditor(jf);
}

case "New Window":
// Load a new text editor instance
Expand Down
18 changes: 16 additions & 2 deletions src/main/java/nz/ac/massey/cs/texteditor/TextEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,23 @@ public class TextEditor extends JFrame {

frame.setSize(1000, 1000);
frame.setVisible(true);
frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
frame.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
}
TextEditor(JFrame window) {
try {
// Remove current window
window.dispose();

// Create new instance
new TextEditor();
}
catch (Exception e) {
System.out.println(e.toString());
}
}
public JFrame getFrame() {
return frame;
}

public JTextArea getTextArea() {
return textArea;
}
Expand Down

0 comments on commit 8550525

Please sign in to comment.