|
-
Jul 6th, 2005, 07:02 PM
#1
Thread Starter
Frenzied Member
Alignment of JList and JComboBox
I would like to know how to set the horizontal alignment of JList's and JComboBox's. I've searched google but can't find anything.
If you know how to do this please let me know.
NOTE: I tried this on the JList but it had no effect:
Code:
JList.setAlignmentX(JList.CENTER_ALIGNMENT);
-
Jul 7th, 2005, 03:19 AM
#2
Re: Alignment of JList and JComboBox
What are you trying to allign. The content in the combobox or the combobox it self?
A JComboBox inheriths from JComponent. And it should have a setAlignmentX() function that takes a float as a parameter. A value that is 0.0 means left, and 1.0 means right.
- ØØ -
-
Jul 7th, 2005, 01:46 PM
#3
Thread Starter
Frenzied Member
Re: Alignment of JList and JComboBox
That still doesn't work. It's not giving any change at all just like the JList did.
-
Jul 7th, 2005, 02:15 PM
#4
Dazed Member
Re: Alignment of JList and JComboBox
Looking at the code System_Error provided it seems he wants to set the alignment of the contents not the Component itself. Same thing as setting the alignment of a JLabel using one of the Constants BOTTOM_ALIGNMENT, CENTER_ALIGNMENT ect ect.
-
Jul 7th, 2005, 02:26 PM
#5
Dazed Member
Re: Alignment of JList and JComboBox
Both classes inherit the fields like LEFT_ALIGNMENT and RIGHT_ALIGNMENT, from java.awt.Componet but don't seem to provide a way to align the their contents via
an arg to the constructor or a set() method.
-
Jul 7th, 2005, 04:48 PM
#6
Thread Starter
Frenzied Member
Re: Alignment of JList and JComboBox
I was searching google and finally found something:
http://forum.java.sun.com/thread.jsp...hreadID=616601
Someone with the same problem as me, but I'm not quit sure of what going on there. Can anyone simplify that or explain a bit?
-
Jul 13th, 2005, 09:57 PM
#7
-
Jul 14th, 2005, 05:19 AM
#8
Addicted Member
Re: Alignment of JList and JComboBox
You could always write a renderer, for the list and the combo box, that centered the content, i mean then you'd only have to center the text in a JLabel which is as easy as doing setHorizontalJustification() or something simialir, i am lacking an API in front of me at the momment and am to lazy to search for one, but its probably teh easiest way to do it...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|