-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEventsPage.java
99 lines (83 loc) · 2.54 KB
/
EventsPage.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.File;
import java.util.Scanner;
public class EventsPage extends JFrame implements ActionListener{
private JButton ButtonAdd,ButtonList;
private JPanel PanelMain;
private Color frameColor=new Color(152, 144, 209);
private String date;
public EventsPage(String date){
super(" Tarikh ");
this.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
this.setResizable(false);
this.setBounds(400,50,350,550);
this.date=date;
PanelMain = new JPanel();
PanelMain.setBounds(0,0,350,550);
PanelMain.setBackground(frameColor);
PanelMain.setLayout(null);
//Button new
ButtonAdd=new JButton("New");
ButtonAdd.setFont(new Font("Roboto",Font.BOLD,18));
ButtonAdd.setBounds(240,20,74,30);
ButtonAdd.setBackground(Color.white);
ButtonAdd.setForeground(frameColor);
ButtonAdd.setFocusPainted(false);
ButtonAdd.setBorderPainted(false);
ButtonAdd.addActionListener(this);
lists();
PanelMain.add(ButtonAdd);
this.add(PanelMain);
}
public void lists(){
try{
File file = new File("currentUser.txt");
Scanner sc= new Scanner(file);
if(sc.hasNextLine()){
String currentUser= sc.nextLine();
currentUser=currentUser.substring(0,currentUser.indexOf("@"));
File file1=new File(currentUser+"-events.txt");
Scanner scc = new Scanner(file1);
int height=80;
while(scc.hasNextLine()){
String line= scc.nextLine();
String eventDate=line.substring(0,line.indexOf("@"));
if(eventDate.equals(date)){
String line1=line.substring(line.indexOf("@")+1);
ButtonList=new JButton(line1);
ButtonList.setFont(new Font("Roboto",Font.PLAIN,18));
ButtonList.setBounds(7,height,320,25);
ButtonList.setBackground(Color.white);
ButtonList.setForeground(frameColor);
ButtonList.setFocusPainted(false);
ButtonList.setBorderPainted(false);
PanelMain.add(ButtonList);
height+=30;
}
}
}
}
catch(Exception ex){
ButtonList=new JButton("NO EVENTS HAS BEEN ADDED");
ButtonList.setFont(new Font("Roboto",Font.PLAIN,18));
ButtonList.setBounds(7,80,320,25);
ButtonList.setBackground(Color.white);
ButtonList.setForeground(Color.red);
ButtonList.setFocusPainted(false);
ButtonList.setBorderPainted(false);
PanelMain.add(ButtonList);
ex.printStackTrace();
}
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==ButtonAdd)
{
CreateEvents e= new CreateEvents(date);
this.setVisible(false);
e.setVisible(true);
}
}
}