|
From: Rogan D. <ro...@da...> - 2007-09-07 08:36:13
|
Andy DePue wrote: > If this is a Swing "feature", then I'm not aware of a simple setting > somewhere (maybe someone else knows of one?). I do know that > DefaultCaret has a setUpdatePolicy method. You would have to get the > Caret from the JTextField, make sure it is a DefaultCaret, cast it to > DefaultCaret, and invoke setUpdatePolicy(DefaultCaret.NEVER_UPDATE). > Even then, I haven't tested this, so I'm not sure if it would have the > desired effect. Another approach would be to implement a > FormComponentInterceptor that automatically handles any JTextField that > is not enabled so that the caret it always placed at the beginning of > the field. See SelectAllFormComponentInterceptorFactory for an example > of what an interceptor looks like. > > - Andy How about calling http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/text/JTextComponent.html#setCaretPosition(int) with a value of 0 after setting the text? Rogan |