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
|
Timer t = new Timer(12000, new ActionListener() {
@Override
public void actionPerformed(ActionEvent ev) {
try {
proc1 = Runtime.getRuntime().exec("acpi -t");
proc2 = Runtime.getRuntime().exec("top -n1 | grep -w 'Cpu(s)'");
proc3 = Runtime.getRuntime().exec("top -n1 | grep -w 'Mem'");
entree1 = new BufferedReader(new InputStreamReader(proc1.getInputStream()));
while ((ligne1 = entree1.readLine()) != null) {
jTextField1.setText(ligne1 + "\n");
}
entree2 = new BufferedReader(new InputStreamReader(proc2.getInputStream()));
while ((ligne2 = entree2.readLine()) != null) {
jTextField2.setText(ligne2 + "\n");
}
entree3 = new BufferedReader(new InputStreamReader(proc3.getInputStream()));
while ((ligne3 = entree3.readLine()) != null) {
jTextField3.setText(ligne3 + "\n");
}
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e.toString(), "Problème", JOptionPane.ERROR_MESSAGE);
}
}
}); |
Partager