Java JTextField FAQ - How do I right-align a JTextField?

Java JTextField question: How do I right-align the text in a JTextField?

Short answer:

myTextField.setHorizontalAlignment(SwingConstants.TRAILING);

Long answer: I need to look at this some more to understand the difference between the alignment constants in SwingConstant and the alignment constants in JTextField.