-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcampususer.java
More file actions
125 lines (110 loc) · 3.72 KB
/
Copy pathcampususer.java
File metadata and controls
125 lines (110 loc) · 3.72 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
package contents;
import java.awt.BorderLayout;
import java.util.Timer;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Scanner;
import java.util.TimeZone;
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.net.URISyntaxException;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import java.awt.Color;
import javax.swing.JTextPane;
import javax.swing.JEditorPane;
import javax.swing.JButton;
import java.util.TimerTask;
public class campususer extends JFrame {
private JPanel contentPane;
public campususer() throws FileNotFoundException, InterruptedException{
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setBackground(Color.BLUE);
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
JLabel lblTime = new JLabel("Time Remaining :");
lblTime.setForeground(Color.RED);
lblTime.setBackground(Color.WHITE);
lblTime.setBounds(224, 11, 120, 20);
contentPane.add(lblTime);
Calendar calendar = Calendar.getInstance(TimeZone.getDefault());
Date date = calendar.getTime();
JLabel lblNewLabel = new JLabel("Connected at timings");
lblNewLabel.setForeground(Color.RED);
lblNewLabel.setBounds(80, 40, 264, 14);
contentPane.add(lblNewLabel);
lblNewLabel.setText("Connected at "+date);
Scanner scanner = new Scanner(new File("C:\\Users\\Nawaz\\Music\\admin.txt"));
final int [] tall = new int [100];
tall[0] = scanner.nextInt();
tall[1] = scanner.nextInt();
scanner.close();
final JEditorPane editorPane = new JEditorPane();
editorPane.setBounds(360, 11, 42, 20);
contentPane.add(editorPane);
editorPane.setEditable(false);
Timer t=new Timer();
TimerTask t1=new TimerTask() {
int sec=tall[0];
public void run()
{
editorPane.setText(String.valueOf(sec));
sec--;
if(sec==0)
{
dispose();
JOptionPane.showMessageDialog(null,"The data is expired","Disconnected",2);
}
}
};
t.scheduleAtFixedRate(t1,1000,1000);
JLabel lblSearchWebsites = new JLabel("Search Websites");
lblSearchWebsites.setForeground(Color.CYAN);
lblSearchWebsites.setBounds(32, 71, 103, 14);
contentPane.add(lblSearchWebsites);
final JEditorPane editorPane_1 = new JEditorPane();
editorPane_1.setBounds(145, 65, 199, 20);
contentPane.add(editorPane_1);
JButton btnGo = new JButton("Go");
btnGo.setBounds(360, 65, 51, 20);
contentPane.add(btnGo);
btnGo.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
try {
FileWriter f=new FileWriter("C:\\Users\\Nawaz\\Music\\users.txt",true);
BufferedWriter b=new BufferedWriter(f);
b.append(editorPane_1.getText());
b.newLine();
b.close();
java.awt.Desktop.getDesktop().browse(new java.net.URI(editorPane_1.getText()));
} catch (IOException e1) {
e1.printStackTrace();
} catch (URISyntaxException e1) {
e1.printStackTrace();
}
}
});
JLabel lblMbsec = new JLabel("Mb/sec");
lblMbsec.setForeground(Color.MAGENTA);
lblMbsec.setBounds(34, 14, 138, 14);
contentPane.add(lblMbsec);
lblMbsec.setText(String.valueOf(tall[1]+" Mbs/second"));
}
}