|
@@ -39,7 +39,7 @@ public class MainUI {
|
|
|
|
|
|
private SubUIController subUIController = null;
|
|
private SubUIController subUIController = null;
|
|
private JFrame jFrame = null;
|
|
private JFrame jFrame = null;
|
|
- OperatingSystemMXBean osBean = null;
|
|
|
|
|
|
+ private final OperatingSystemMXBean osBean = (com.sun.management.OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
|
|
private Timer timer;
|
|
private Timer timer;
|
|
private Long tick = Long.valueOf(0);
|
|
private Long tick = Long.valueOf(0);
|
|
private TbPisInfr selObj = null;
|
|
private TbPisInfr selObj = null;
|
|
@@ -82,10 +82,22 @@ public class MainUI {
|
|
}
|
|
}
|
|
|
|
|
|
public void displayResource() {
|
|
public void displayResource() {
|
|
|
|
+ //OperatingSystemMXBean osBean = (OperatingSystemMXBean)ManagementFactory.getOperatingSystemMXBean();
|
|
long memoryUsage = Math.round(((double) (osBean.getTotalPhysicalMemorySize() - osBean.getFreePhysicalMemorySize())) / (double) osBean.getTotalPhysicalMemorySize() * 100.0);
|
|
long memoryUsage = Math.round(((double) (osBean.getTotalPhysicalMemorySize() - osBean.getFreePhysicalMemorySize())) / (double) osBean.getTotalPhysicalMemorySize() * 100.0);
|
|
lblMemoryUsage.setText(String.valueOf(memoryUsage));
|
|
lblMemoryUsage.setText(String.valueOf(memoryUsage));
|
|
double cpuLoad = osBean.getSystemCpuLoad();
|
|
double cpuLoad = osBean.getSystemCpuLoad();
|
|
- lblCpuRate.setText(String.valueOf(Math.round(cpuLoad * 100.0)));
|
|
|
|
|
|
+ if (cpuLoad >= 0.0 && cpuLoad <= 1.0) {
|
|
|
|
+ lblCpuRate.setText(String.valueOf(Math.round(cpuLoad * 100.0)));
|
|
|
|
+ } else {
|
|
|
|
+ lblCpuRate.setText("---");
|
|
|
|
+ }
|
|
|
|
+// if (osBean instanceof com.sun.management.OperatingSystemMXBean) {
|
|
|
|
+// com.sun.management.OperatingSystemMXBean nativeOsBean = (com.sun.management.OperatingSystemMXBean)osBean;
|
|
|
|
+// log.error("CPU LOAD: {}", Math.ceil(nativeOsBean.getSystemCpuLoad() * 100.0));
|
|
|
|
+// }
|
|
|
|
+// else {
|
|
|
|
+// log.error("You're not using Oracle Java nor using the native library. You won't be able to read some native data");
|
|
|
|
+// }
|
|
}
|
|
}
|
|
|
|
|
|
public MainUI(JFrame jFrame) {
|
|
public MainUI(JFrame jFrame) {
|
|
@@ -98,7 +110,9 @@ public class MainUI {
|
|
subUIController.setVisible(false);
|
|
subUIController.setVisible(false);
|
|
}
|
|
}
|
|
|
|
|
|
- osBean = ManagementFactory.getPlatformMXBean(OperatingSystemMXBean.class);
|
|
|
|
|
|
+ //OperatingSystemMXBean mbean = (com.sun.management.OperatingSystemMXBean)ManagementFactory.getOperatingSystemMXBean();
|
|
|
|
+ //osBean = ManagementFactory.getPlatformMXBean(OperatingSystemMXBean.class);
|
|
|
|
+ //osBean = (OperatingSystemMXBean) ManagementFactoryHelper.getOperatingSystemMXBean();
|
|
try {
|
|
try {
|
|
Font font = Font.createFont(Font.TRUETYPE_FONT, new File("fonts/D2Coding.ttc"));
|
|
Font font = Font.createFont(Font.TRUETYPE_FONT, new File("fonts/D2Coding.ttc"));
|
|
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
|
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
|