/** * Paints the error marker. * * @param g graphics reference */ private void drawError(final Graphics g) { final int ww = wordW != 0 ? wordW : charW(g, ' '); final int s = Math.max(1, fontH / 8); g.setColor(GUIConstants.LRED); g.fillRect(x, y + 2, ww, s); g.setColor(GUIConstants.RED); for (int xp = x; xp < x + ww; xp++) { if ((xp & 1) == 0) g.drawLine(xp, y + 2, xp, y + s + 1); } }
@Override public void paintComponent(final Graphics g) { super.paintComponent(g); final Runtime rt = Runtime.getRuntime(); final long max = rt.maxMemory(); final long total = rt.totalMemory(); final long used = total - rt.freeMemory(); final int ww = getWidth(); final int hh = getHeight(); // draw memory box g.setColor(Color.white); g.fillRect(0, 0, ww - 3, hh - 3); g.setColor(GRAY); g.drawLine(0, 0, ww - 4, 0); g.drawLine(0, 0, 0, hh - 4); g.drawLine(ww - 3, 0, ww - 3, hh - 3); g.drawLine(0, hh - 3, ww - 3, hh - 3); // show total memory usage g.setColor(color1); g.fillRect(2, 2, Math.max(1, (int) (total * (ww - 6) / max)), hh - 6); // show current memory usage final boolean full = used * 6 / 5 > max; g.setColor(full ? colormark4 : color3); g.fillRect(2, 2, Math.max(1, (int) (used * (ww - 6) / max)), hh - 6); // print current memory usage final FontMetrics fm = g.getFontMetrics(); final String mem = Performance.format(used, true); final int fw = (ww - fm.stringWidth(mem)) / 2; final int h = fm.getHeight() - 3; g.setColor(full ? colormark3 : DGRAY); g.drawString(mem, fw, h); }
/** * Paints the text cursor. * * @param g graphics reference * @param xx x position */ private void cursor(final Graphics g, final int xx) { g.setColor(Color.black); g.drawLine(xx, y - fontH + 4, xx, y + 3); }