-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyEditor.java
More file actions
170 lines (167 loc) · 7.71 KB
/
MyEditor.java
File metadata and controls
170 lines (167 loc) · 7.71 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class MyEditor extends JFrame
{
JFrame frame;
JTextArea textarea,input;
JMenuBar menubar;
JMenu menu1,menu2,menu3;
JMenuItem newfile,open_file,close,save,cut,copy,paste,compile,run,save_as;
JScrollPane scroll,scroll_in,scroll_out;
JPopupMenu options;
JTextPane statusbar,output;
MyEditor()
{
Utilities.setNativeLookAndFeel();
frame=new JFrame("MyEditor");
Working working=new Working(this);
DoEvent work=new DoEvent(this,working);
frame.setLayout(null);
Font f1=new Font("Constantia",Font.PLAIN,24);
textarea=new JTextArea();
textarea.setBackground(new Color(255,255,200));
textarea.setFont(f1);
menubar=new JMenuBar();
menu1=new JMenu("File");
menu1.setOpaque(true);
menu2=new JMenu("Edit");
menu2.setOpaque(true);
menu3=new JMenu("Operations");
menu3.setOpaque(true);
menu1.setMnemonic(KeyEvent.VK_F);
menu2.setMnemonic(KeyEvent.VK_E);
menu3.setMnemonic(KeyEvent.VK_P);
menu1.addMouseListener(work);
menu2.addMouseListener(work);
menu3.addMouseListener(work);
ImageIcon open=new ImageIcon(getClass().getResource("images/open2.png"));
ImageIcon edit=new ImageIcon(getClass().getResource("images/edit.png"));
ImageIcon operations=new ImageIcon(getClass().getResource("images/operations.png"));
menu1.setIcon(open);
menu2.setIcon(edit);
menu3.setIcon(operations);
newfile=new JMenuItem("New File");
newfile.setIcon(new ImageIcon(getClass().getResource("images/new.png")));
newfile.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N,ActionEvent.CTRL_MASK));
newfile.addActionListener(work);
close=new JMenuItem("Close");
close.setIcon(new ImageIcon(getClass().getResource("images/close.png")));
close.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E,ActionEvent.CTRL_MASK));
close.addActionListener(work);
compile=new JMenuItem("Compile");
compile.setIcon(new ImageIcon(getClass().getResource("images/compile.png")));
compile.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_M,ActionEvent.CTRL_MASK));
compile.addActionListener(work);
run=new JMenuItem("Run");
run.setIcon(new ImageIcon(getClass().getResource("images/run.png")));
run.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R,ActionEvent.CTRL_MASK));
run.addActionListener(work);
save=new JMenuItem("Save");
save.setIcon(new ImageIcon(getClass().getResource("images/save.png")));
save.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,ActionEvent.CTRL_MASK));
save.addActionListener(work);
save_as=new JMenuItem("Save As");
save_as.setIcon(new ImageIcon(getClass().getResource("images/save_as.png")));
save_as.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,ActionEvent.ALT_MASK));
save_as.addActionListener(work);
cut=new JMenuItem("Cut");
cut.setIcon(new ImageIcon(getClass().getResource("images/cut.png")));
cut.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X,ActionEvent.CTRL_MASK));
cut.addActionListener(work);
menu2.add(cut);
menu2.addSeparator();
copy=new JMenuItem("Copy");
copy.setIcon(new ImageIcon(getClass().getResource("images/copy.png")));
copy.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C,ActionEvent.CTRL_MASK));
copy.addActionListener(work);
menu2.add(copy);
menu2.addSeparator();
paste=new JMenuItem("Paste");
paste.setIcon(new ImageIcon(getClass().getResource("images/paste.png")));
paste.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V,ActionEvent.CTRL_MASK));
paste.addActionListener(work);
menu2.add(paste);
open_file=new JMenuItem("Open");
open_file.setIcon(new ImageIcon(getClass().getResource("images/open.png")));
open_file.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O,ActionEvent.CTRL_MASK));
open_file.addActionListener(work);
menu1.add(newfile);
menu1.addSeparator();
menu1.add(open_file);
menu1.addSeparator();
menu1.add(close);
menu3.add(save);
menu3.addSeparator();
menu3.add(save_as);
menu3.addSeparator();
menu3.add(compile);
menu3.addSeparator();
menu3.add(run);
menubar.add(menu1);
menubar.add(menu2);
menubar.add(menu3);
frame.setJMenuBar(menubar);
//adding the textarea
scroll=new JScrollPane(textarea);
scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scroll.setBounds(20,45,1350,780);
frame.add(scroll);
//adding the standard input ui
input=new JTextArea();
input.setFont(new Font("Monospaced",Font.BOLD,18));
JScrollPane scroll_in=new JScrollPane(input);
scroll_in.setBounds(1375,45,540,430);
scroll_in.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
scroll_in.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
frame.add(scroll_in);
//adding the standard output ui
output=new JTextPane();
output.setEditable(false);
output.setFont(new Font("Monospaced",Font.BOLD,18));
JScrollPane scroll_out=new JScrollPane(output);
scroll_out.setBounds(1375,520,540,420);
scroll_out.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
scroll_out.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
frame.add(scroll_out);
//adding the label of standard input and standard output
JLabel stdin=new JLabel();
JLabel stdout=new JLabel();
stdin.setBounds(1380,20,540,20);
stdin.setText("\tStandard Input :");
stdin.setFont(new Font("Arial",Font.BOLD,14));
frame.add(stdin);
stdout.setBounds(1380,490,540,20);
stdout.setText("\tStandard Output :");
stdout.setFont(new Font("Arial",Font.BOLD,14));
frame.add(stdout);
//adding the status bar;
JLabel statusbarname=new JLabel();
statusbarname.setBounds(20,830,1350,30);
statusbarname.setFont(new Font("Arial",Font.BOLD,14));
statusbarname.setText("\tStatus Bar :");
frame.add(statusbarname);
statusbar=new JTextPane();
statusbar.setEditable(false);
statusbar.setText("Enter your java code");
statusbar.setBounds(20,870,1350,60);
statusbar.setFont(new Font("Arial",Font.BOLD,20));
frame.add(statusbar);
//adding the textarea name
JLabel textareaname=new JLabel();
textareaname.setBounds(20,15,1350,20);
textareaname.setFont(new Font("Arial",Font.BOLD,14));
textareaname.setText(" Enter your java code here :");
frame.add(textareaname);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
frame.getContentPane().setBackground(new Color(240,230,255));
frame.pack();
frame.setVisible(true);
}
public static void main(String args[])
{
new MyEditor();
}
}