当我设置字体跟踪时,我无法用鼠标选择最后一个字母。请看这个例子:
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);
}
});
}
}