Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: User Interface Design
Expertise: Beginner
Feb 15, 2000

Textfield Alignment

Question:
How do I right align numbers in a textfield?

Answer:
This is yet another example of why the Swing classes should be used in lieu of the AWT classes. Swing components contain a significant degree of added functionality not included in the base AWT package.

The java.awt.TextField does not support the customization of text alignment. However, javax.swing.JTextField does. It includes a method called setHorizontalAlignment which can take an argument of JTextField.LEFT, JTextField.CENTER, or JTextField.RIGHT to customize the text alignment. For your situation, you would use JTextField.RIGHT.

DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap