• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Right Alignment of JTextField

 
Paul Keohan
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I want to enter text from the right side of a JTextField what do I need to do?
I have a JTextField object called jtf
I do :
jtf.setHorizontalAlignment(JTextField.RIGHT_ALIGNMENT)
Firstly this doesn't compile because the field is a float but the method expects an int. When I cast it to int it compiles alright but I get a runtime error saying it's an invalid parameter.
Any ideas?
Paul
 
Chad McGowan
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For setHorizontalAlignment(), you need to use JTextField.RIGHT
Chad
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic