-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMinecraftEditor.java
77 lines (62 loc) · 1.55 KB
/
MinecraftEditor.java
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/**
* @(#)MinecraftEditor.java
*
*
* @author
* @version 1.00 2015/3/10
*/
import java.awt.BorderLayout;
import javax.swing.JTextArea;
import javax.swing.JPanel;
//import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.ScrollPaneConstants;
import java.io.File;
public class MinecraftEditor extends JPanel
{
private JTextArea editor;
private File file;
private String lastSave = "";
public MinecraftEditor(File f)
{
file = f;
editor = new JTextArea();
editor.setEditable(true);
JScrollPane qScroller = new JScrollPane(editor);
qScroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
qScroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
setLayout(new BorderLayout());
add(qScroller,BorderLayout.CENTER);
}
public void addLine(String line)
{
editor.append(line + "\r\n");
}
public String getText()
{
return editor.getText();
}
public void setFile(File f)
{
file = f;
}
public File getFile()
{
return file;
}
public boolean isSaved()
{
return (lastSave.equals(editor.getText()));
}
public void save()
{
lastSave = editor.getText();
}
/*public static void main(String[] args)
{
JFrame frame = new JFrame();
frame.getContentPane().add(BorderLayout.CENTER, new MinecraftEditor());
frame.setSize(600,400);
frame.setVisible(true);
}*/
}