Click « Text Input « Java Swing Q&A





1. can't set cursor placement when clicking in a JFormattedTextField...    coderanch.com

Rob, Thanks. Didn't work. Here's what I did... MaskFormatter eightCharMax = null; try { eightCharMax = new MaskFormatter("********"); } catch (ParseException e) { // Swallow exception } ... customerIDField = new JFormattedTextField(eightCharMax); customerIDField.addFocusListener(new CustomerIDFieldFocusListener()); ... private class CustomerIDFieldFocusListener implements FocusListener { public void focusGained(FocusEvent e) { JFormattedTextField field = (JFormattedTextField) e.getSource(); field.setCaretPosition(0); } public void focusLost(FocusEvent e) { JFormattedTextField field = ...