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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting cell text alignment in JTable

Status
Not open for further replies.

phimlob

Programmer
Apr 5, 2000
9
SE
Hi all :)<br><br>I really need help with this... I have a JTable, and I want to be able to right/left/center justify text in individual cells. Not entire columns. I've looked around a heck of a lot, but I just cant find any methods...<br><br>I was hoping I could place an example html table here just to show what I mean... but if anyone has any questions, please email me at: <A HREF="mailto:mattias@redeye.se">mattias@redeye.se</A><br><br>I hope someone out there can help me out!<br><br>/Mattias<br><br>
 
&nbsp;&nbsp;Each cell is displayed by a 'renderer' object when read-only, and an 'editor' object while being edited. The default cell renderer for text is a JLabel, and the default cell editor is a JTextArea.<br>&nbsp;&nbsp;Try overriding the JTable's createDefaultRenderers() method to create JLabels and invoke setHorizontalTextPosition(int textPosition) for them.
 
Thanks- Ill give it a shot :)<br>/Mattias
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top