File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Position text field content left side Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Position text field content left side" Watch "Position text field content left side" New topic
Author

Position text field content left side

John Jai
Bartender

Joined: May 31, 2011
Posts: 1776
Hi,

Please help me to show the content of the JText field from the starting point (first letter from left - and in below eg. the "haii" should be visible). I tried setting the alignment to LEFT but it did not work. And the text field will not be enabled.

code -
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38480
    
  23
I tried it and found nothing wrong with it. Your text is longer than the text field, so you only see its right end. Try with shorter text, eg "Campbell", and you can see it appears as |Campbell       |
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10268
    
    8

setCaretPosition(0);


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
John Jai
Bartender

Joined: May 31, 2011
Posts: 1776
Campbell - that is the issue... when the text was bigger I want it to show from the starting position. setCaretPositioin(0) is working fine.
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> And the text field will not be enabled.

'horses for courses' - a JLabel would not have had this problem.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38480
    
  23
Thank you, Maneesh
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Position text field content left side