char[] line = new char[SCREEN_WIDTH]; for (int j = 0; j < SCREEN_WIDTH; j++) { line[j] = offset + j == cursorOffset ? '_' : ' '; } g.drawChars(line, 0, lenght, margin, h + i * h);
FontMetrics fm = getFontMetrics(getFont()); int x = margin + fm.charsWidth(buffer, offset, cursorOffset - offset); int y = h + i * h; int width = fm.charWidth(buffer[cursorOffset]); g.drawLine(x, y, x+width, y);
        protected void paintComponent(Graphics g) {            g.setColor(getBackground());            g.fillRect(0, 0, getWidth(), getHeight());            g.setColor(Color.WHITE);            for (int i = 0; i < SCREEN_HEIGHT; i++) {                int offset = i * SCREEN_WIDTH;                int lenght = SCREEN_WIDTH;                if (offset <= cursorOffset && cursorOffset < offset + SCREEN_WIDTH) {                    char[] line = new char[SCREEN_WIDTH];                    for (int j = 0; j < SCREEN_WIDTH; j++) {                        line[j] = offset + j == cursorOffset ? '_' : ' ';                    }                    g.drawChars(line, 0, lenght, margin, h + i * h);                }                g.drawChars(buffer, offset, lenght, margin, h + i * h);            }        }