Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Andrzejek on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Center align the contents of a TextField

Status
Not open for further replies.

paulbradley

Programmer
Oct 9, 2002
158
GB
Sounds basic but when I write

tN = new TextField("1");
tN.setAlignment(CENTER);

I get "cannot find symbol" error, despite the JAVA Api says I should be able to.

Any ideas for center alignment of text field? Thanks.
 
If you're willing to use Swing rather than AWT, I offer you the following:

Code:
        JTextField fld = new JTextField();
        fld.setHorizontalAlignment(JTextField.CENTER);

Hope this helps!

Rich
 
Many thanks, but I would rather stick to AWT, any way of doing it with bog-standard TextFields ? Cheers
 
I can't find anything.

Tim
---------------------------
"Your morbid fear of losing,
destroys the lives you're using." - Ozzy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top