-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathEditor.java
More file actions
44 lines (38 loc) · 798 Bytes
/
Editor.java
File metadata and controls
44 lines (38 loc) · 798 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import javax.swing.JEditorPane;
/**
*
* @author Victoria
*
* Editor where source code is loaded and edited
*
*/
@SuppressWarnings("serial")
public class Editor extends JEditorPane {
private String code;
public Editor() {
setEditable(false);
((PlainDocument) getDocument()).putProperty(PlainDocument.tabSizeAttribute, 2);
}
/**
* Sets new code to be displayed
* @param file new code to be displayed
*/
public void updateCode(String code) {
this.code = code;
setEditable(true);
display();
}
/**
* Displays HTML page or gives error screen if file cannot be loaded
* Prompts to choose a file if file is null
*/
public void display() {
setText(code);
}
/**
* Returns code typed in editor pane
*/
public String getCode() {
return getText();
}
}