Why can't I select the last letter when I install font tracking

When I install font tracking, I cannot select the last letter with the mouse. Please see this example:

 public class TrackingTest extends JFrame {

        public TrackingTest(String text) {
            addContent(text);
        }

        private void addContent(String text) {
            JTextField field = new JTextField(10);
            Map att = new HashMap();
            att.put(TextAttribute.SIZE, 20);
            att.put(TextAttribute.FAMILY, "Arial");
            att.put(TextAttribute.TRACKING, 1.0f);
            Font font = Font.getFont(att);
            field.setFont(font);
            field.setText(text);
            getContentPane().add(field);

        }

        public static void main(String args[]) {
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    final TrackingTest test = new TrackingTest("abcdeas");
                            test.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
                    test.pack();
                    test.setVisible(true);
                }
            });
        }
    }

      

+3


source to share





All Articles