/** @inheritDoc */ public void drawTextField(Graphics g, TextField ta) { if (ta instanceof DateField) { drawDateField(g, (DateField) ta); return; } setFG(g, ta); // display ******** if it is a password field String displayText = getTextFieldString(ta); Style style = ta.getStyle(); int x = 0; int cursorCharPosition = ta.getCursorPosition(); Font f = ta.getStyle().getFont(); int cursorX = 0; int xPos = 0; if (cursorCharPosition > 0) { xPos = f.stringWidth(displayText.substring(0, cursorCharPosition)); cursorX = ta.getX() + style.getPadding(Component.LEFT) + xPos; if (ta.getWidth() > (f.getHeight() * 2) && cursorX >= ta.getWidth() - style.getPadding(Component.LEFT)) { while (x + xPos >= ta.getWidth() - style.getPadding(Component.LEFT) * 2) { x--; } } } g.drawString( displayText, ta.getX() + x + style.getPadding(Component.LEFT), ta.getY() + style.getPadding(Component.TOP)); // show always if (ta.getInputModeOrder() != null && ta.getInputModeOrder().length > 0) { String inputMode = ta.getInputMode(); int inputModeWidth = f.stringWidth(inputMode); if (ta.handlesInput() && ta.getWidth() / 2 > inputModeWidth) { int drawXPos = ta.getX() + style.getPadding(Component.LEFT) - 1; if (xPos < ta.getWidth() / 2) { // draw on the right side drawXPos = drawXPos + ta.getWidth() - inputModeWidth - style.getPadding(Component.RIGHT) - style.getPadding(Component.LEFT); } g.setColor(style.getFgSelectionColor()); // unfurtanally g.fillroundrect does not suppport alpha // g.fillRoundRect(drawXPos, ta.getY() + style.getPadding(Component.TOP)-1, inputModeWidth, // ta.getHeight()-4, 4, 4); // so a work around is required byte alphaLevel = (byte) 140; g.fillRect( drawXPos, ta.getY() + style.getPadding(Component.TOP) - 1, inputModeWidth + 2, ta.getHeight() - 4, alphaLevel); // g.setColor(0xFF0000); g.setColor(style.getBgSelectionColor()); g.fillRect(drawXPos, ta.getY() + style.getPadding(Component.TOP) - 1, 1, 1, alphaLevel); g.fillRect( drawXPos + inputModeWidth + 1, ta.getY() + style.getPadding(Component.TOP) - 1, 1, 1, alphaLevel); g.fillRect( drawXPos + inputModeWidth + 1, ta.getY() + style.getPadding(Component.TOP) - 1 + ta.getHeight() - 4 - 1, 1, 1, alphaLevel); g.fillRect( drawXPos, ta.getY() + style.getPadding(Component.TOP) - 1 + ta.getHeight() - 4 - 1, 1, 1, alphaLevel); g.drawString(inputMode, drawXPos + 1, ta.getY() + style.getPadding(Component.TOP)); } } }