-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDoEvent.java
More file actions
90 lines (87 loc) · 2.53 KB
/
DoEvent.java
File metadata and controls
90 lines (87 loc) · 2.53 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
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.IOException;
class DoEvent extends MouseAdapter implements ActionListener,MouseListener
{
MyEditor editor;
Color c; //default color of menubar
Working working;
DoEvent(MyEditor editor,Working working)
{
this.editor=editor;
this.working=working;
}
public void actionPerformed(ActionEvent event)
{
if(event.getSource()==editor.close) //for closing
{
System.exit(1);
}
else if(event.getSource()==editor.open_file)
{
try{
working.open_file();
}catch(IOException e){}
}
else if(event.getSource()==editor.save) //for saving
{
working.save();
}
else if(event.getSource()==editor.compile) //for compiling
{
boolean is_file_compiled=working.compile();
if(is_file_compiled==true)
{
System.out.println("File compiled successfully");
}
}
else if(event.getSource()==editor.run)
{
try{
working.run_code();
}catch(IOException e){}
catch(ClassNotFoundException e){}
}
else if(event.getSource()==editor.copy) //to copy
{
editor.textarea.copy();
}
else if(event.getSource()==editor.cut) //to cut
{
editor.textarea.cut();
}
else if(event.getSource()==editor.paste) //to paste
{
editor.textarea.paste();
}
else if(event.getSource()==editor.newfile)
{
working.newfile();
}
else if(event.getSource()==editor.save_as)
{
working.save_as();
}
}
public void mouseEntered(MouseEvent mevent)
{
if(mevent.getSource()==editor.menu1||mevent.getSource()==editor.menu2||mevent.getSource()==editor.menu3)
{
this.c=editor.menu1.getBackground();
JMenu item=(JMenu)mevent.getSource();
item.setBackground(new Color(150,150,180));
}
}
//------------------------------------------------
public void mouseExited(MouseEvent mevent)
{
if(mevent.getSource()==editor.menu1 || mevent.getSource()==editor.menu2 ||mevent.getSource()==editor.menu3)
{
JMenu item=(JMenu)mevent.getSource();
item.setBackground(this.c);
}
}
//-------------------------------------------------
//-------------------------------------------------------
}