void (Graphics g) { Dimension size = getSize(); int barWidth = size.width; Runtime rt = Runtime.getRuntime(); long maxMem = rt.maxMemory(); long allocatedMem = rt.totalMemory(); long unusedMem = rt.freeMemory(); long usedMem = allocatedMem - unusedMem; int usedBarLength = (int)(barWidth * usedMem / maxMem); int allocatedBarLength = (int)(barWidth * allocatedMem / maxMem); // background g.setColor(UIUtil.getPanelBackground()); g.fillRect(0, 0, barWidth, size.height); // gauge (allocated) g.setColor(myUnusedColor); g.fillRect(0, 0, allocatedBarLength, size.height); // gauge (used) g.setColor(myUsedColor); g.fillRect(0, 0, usedBarLength, size.height); //text super.paintComponent(g); }