Results 1 to 5 of 5
Thread: Alignment using BoxLayout
- 01-22-2010, 08:34 PM #1
Member
- Join Date
- Jan 2010
- Posts
- 3
- Rep Power
- 0
Alignment using BoxLayout
Hi all,
I have been recently experimenting with the "setAlignmentX()" and "setAlignmentY()" methods within the context of a BoxLayout, and all appeared well until I began adding "Box.createRigidArea(..)" components.
As the rigid area return type is "Component" as opposed to "JComponent", I am unable to invoke the above methods in order to retain a consistent alignment strategy within the parent container.
Does anyone know a way in which I can set the appropriate alignments of the objects returned by "Box.createRigidArea(..)"?
Best regards, Gemma.
- 01-23-2010, 04:32 PM #2
Senior Member
- Join Date
- Aug 2009
- Location
- Pittsburgh, PA
- Posts
- 284
- Rep Power
- 4
Checking the Box.java code, we can see that Box.createRigidArea(...)
returns an object which is in fact a JComponent.
So a rigid area with an alignment can be created with
Java Code:JComponent rigidArea = (JComponent)Box.createRigidArea(...); rigidArea.setAlignmentX(...);
- 01-23-2010, 06:35 PM #3
Member
- Join Date
- Jan 2010
- Posts
- 3
- Rep Power
- 0
So simple, yet utterly brilliant!!!
Being neither confident nor competent enough to trawl through JDK source code, I would like to thank you for your time in securing the information that has eluded me for several days.
Again, thank you for allowing me to put this issue to bed and move on to my next assignment.
All the best, Gemma xxx
-
Don't forget to "rep" him for his helpful advice. ;)
- 01-23-2010, 07:15 PM #5
Member
- Join Date
- Jan 2010
- Posts
- 3
- Rep Power
- 0
Similar Threads
-
BoxLayout problems
By paulb in forum New To JavaReplies: 2Last Post: 11-04-2009, 10:04 PM -
BoxLayout Behaviour
By PetalumaBoy in forum AWT / SwingReplies: 4Last Post: 06-10-2009, 01:27 PM -
[SOLVED] I share BoxLayout with Conteiner but it doesn' t work
By Wolverine in forum AWT / SwingReplies: 7Last Post: 05-22-2009, 03:57 AM -
[SOLVED] Possible to have two BoxLayout in same area of BorderLayout?
By mainy in forum AWT / SwingReplies: 4Last Post: 02-16-2009, 09:52 PM -
Label Alignment Example
By Java Tip in forum javax.swingReplies: 0Last Post: 06-27-2008, 07:49 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks