-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQUESTUtility.java
More file actions
109 lines (100 loc) · 2.51 KB
/
Copy pathQUESTUtility.java
File metadata and controls
109 lines (100 loc) · 2.51 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
package quest;
import java.awt.Color;
import java.awt.Font;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import javax.swing.*;
public class QUESTUtility
{
static boolean clearCacheFlag = true;
static JButton createButton(String name, int fontsize)
{
JButton b = new JButton(name);
Font f = new Font("Times New Roman", Font.BOLD, fontsize);
b.setFont(f);
return b;
}
static JButton createBigButton(String name)
{
JButton b = new JButton(name);
Font f = new Font(QUESTConstants.COMPONENT_FONT, Font.BOLD, QUESTConstants.HEADING_FONT_SIZE);
return b;
}
static JLabel createLabel(String name, int fontsize)
{
JLabel l = new JLabel(name);
Font f = new Font("Times New Roman", Font.BOLD, fontsize);//16);
l.setFont(f);
return(l);
}
static JLabel createInfoLable(String name)
{
JLabel l = new JLabel(name);
Font f = new Font(QUESTConstants.TEXT_FONT, Font.PLAIN, QUESTConstants.LARGE_FONT_SIZE);
l.setFont(f);
return(l);
}
static JLabel createHeadingLabel(String name)
{
JLabel l = new JLabel(name);
Font f = new Font(QUESTConstants.TEXT_FONT, Font.PLAIN, QUESTConstants.MEDIUM_FONT_SIZE); //For demo
l.setFont(f);
return(l);
}
static JLabel createContourLabel(String name)
{
JLabel l = new JLabel(name);
Font f = new Font(QUESTConstants.TEXT_FONT, Font.PLAIN, QUESTConstants.MEDIUM_FONT_SIZE); //For demo
l.setFont(f);
return(l);
}
static JLabel createBigHeadingLabel(String name)
{
JLabel l = new JLabel(name);
Font f = new Font(QUESTConstants.TEXT_FONT, Font.BOLD, 24); //For demo
l.setFont(f);
return(l);
}
static JRadioButton createRadioButton(String name, int color)
{
JRadioButton r = new JRadioButton(name);
r.setForeground(new Color(color));
Font f = new Font(QUESTConstants.COMPONENT_FONT, Font.BOLD, QUESTConstants.LARGE_FONT_SIZE); //For demo
r.setFont(f);
return(r);
}
public static boolean clearCache()
{
boolean success = false;
if(clearCacheFlag)
{
String[] cmd = {
"/bin/sh",
"-c",
"echo 3 | sudo tee /proc/sys/vm/drop_caches"
};
Process p;
try
{
Runtime r = Runtime.getRuntime();
p = r.exec(cmd);
p.waitFor();
BufferedReader reader =
new BufferedReader(new InputStreamReader(p.getInputStream()));
String line = "";
while ((line = reader.readLine())!= null)
{
if(line.equals("3"))
{
success = true;
}
System.out.println(line);
}
} catch (Exception e)
{
e.printStackTrace();
}
}
return(success);
}
}