Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 JButton Alignment
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
UnusedUsername




PostPosted: Tue Jul 24, 2007 10:57 am   Post subject: JButton Alignment

I want to create JButtons with text positioned to their very left.

I've tried using setHorizontalAlignment(), setHorizontalTextPosition() and setMargins() but none of them can create the desired effect.

Does anyone know how to do this?
Sponsor
Sponsor
Sponsor
sponsor
Aziz




PostPosted: Tue Jul 24, 2007 1:54 pm   Post subject: RE:JButton Alignment

Hmm, good question. Perhaps it's not an alignment iissue, but an issue with the inner borders/padding of buttons?

Try reading the Swing Tutorial:

http://java.sun.com/docs/books/tutorial/uiswing/components/button.html
UnusedUsername




PostPosted: Tue Jul 24, 2007 4:33 pm   Post subject: RE:JButton Alignment

After reading it, I don't think it can be done, which is rather odd.
rizzix




PostPosted: Tue Jul 24, 2007 4:42 pm   Post subject: RE:JButton Alignment

It is definitely possible.

code:
button.setHorizontalAlignment(SwingConstants.LEFT);


To make it such that the text is positioned to the far left, you'd have to pass appropriate Insets to setMargin(); and reduce the gap to Zero.
UnusedUsername




PostPosted: Wed Jul 25, 2007 7:06 am   Post subject: RE:JButton Alignment

I see how it works now. I have to use setAlignment() in conjunction with setMargins(). Thanks for the help guys (or gals).
Aziz




PostPosted: Wed Jul 25, 2007 8:42 am   Post subject: RE:JButton Alignment

Guys. Definitely guys. Unless you're hiding something, rizzix? Anyways, glad we could help. Java Tutorials + API documentation (and the occasional google) is one of a java programmer's best assets.
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 6 Posts ]
Jump to:   


Style:  
Search: