Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / August 2005

Tip: Looking for answers? Try searching our database.

How to introduce padding for JTable cell text

Thread view: 
Austin - 24 Aug 2005 06:57 GMT
Hi experts,

I am working with JTables containing (left aligned) columns. I would
like to introduce a uniform left-padding for all cells (say single
space, or 3 pixels) so that the text in each doesn't appear too close
to the left cell border.

Is there a simple way to achieve this? Thanks in advance.

Austin.
Thomas Fritsch - 24 Aug 2005 12:27 GMT
> Hi experts,
>
[quoted text clipped - 6 lines]
>
> Austin.

Seems like you want JTable#setIntercellSpacing(Dimension).
Try  yourTable.setIntercellSpacing(new Dimension(3,0));

Signature

"Thomas:Fritsch$ops:de".replace(':','.').replace('$','@')

Vova Reznik - 24 Aug 2005 16:32 GMT
>> Hi experts,
>>
[quoted text clipped - 9 lines]
> Seems like you want JTable#setIntercellSpacing(Dimension).
> Try  yourTable.setIntercellSpacing(new Dimension(3,0));

That operation will add space for both sides left and right.
Think about your cell as JLabel (DefaultTableCellRenderer is JLabel)
if you don't use custom renderer.
I will recommend you to override LabelUI (some of its subclasses)- it is
the place
where label is being painted (look in paintEnabledText).
Pete Barrett - 24 Aug 2005 18:29 GMT
>Hi experts,
>
[quoted text clipped - 4 lines]
>
>Is there a simple way to achieve this? Thanks in advance.

If you're using a custom Renderer for the cells, you can put in
whatever spacing (as an EmptyBorder) that you like.

Pete Barrett
Vova Reznik - 24 Aug 2005 18:51 GMT
>>Hi experts,
>>
[quoted text clipped - 9 lines]
>
> Pete Barrett
You will lose some futures (red border if wrong data type entered for
example)
Andrew Thompson - 24 Aug 2005 18:57 GMT
..
>>>I am working with JTables containing (left aligned) columns. I would
>>>like to introduce a uniform left-padding for all cells (say single
>>>space, or 3 pixels)
..
>> If you're using a custom Renderer for the cells, you can put in
>> whatever spacing (as an EmptyBorder) that you like.
..
> You will lose some futures

It sounds like you mean 'features'..

(..as opposed to 'future' - events yet to happen.)

>..(red border if wrong data type entered for
> example)

Signature

Andrew Thompson
physci.org 1point1c.org javasaver.com lensescapes.com athompson.info
"What did you bring me, dear mother, to keep me from the gallis' pole?"
Leadbelly 'The Gallis' Pole'

Vova Reznik - 24 Aug 2005 19:02 GMT
>>You will lose some futures
> It sounds like you mean 'features'..
>
> (..as opposed to 'future' - events yet to happen.)

Y :), didn't find forum with Russian language :)
Andrew Thompson - 24 Aug 2005 19:14 GMT
>>>You will lose some futures
>> It sounds like you mean 'features'..
>>
>> (..as opposed to 'future' - events yet to happen.)
>
> Y :), didn't find forum with Russian language :)

Your English is far better than my Russian.  ;)

Signature

Andrew Thompson
physci.org 1point1c.org javasaver.com lensescapes.com athompson.info
"You may be subject to fits of hysterical shouting, or even laughter.."
Hawkwind 'Sonic Attack'



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.