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 / General / November 2005

Tip: Looking for answers? Try searching our database.

jtable text size

Thread view: 
tiewknvc9 - 29 Nov 2005 14:33 GMT
Hi!

Im working with an extended jtable, in the constructor, I set the font
size and the rowHeight,

htfFont = new Font("Courier", Font.PLAIN, 15);
this.setFont(htfFont);
this.setRowHeight(htfFont.getSize() + 3);

the font seems to only take effect after exiting the cell, when it is
being editted it looks quite small. I would expect that there should be
an easy way to do this rather than creating a new tablecelleditor and
tablecellrenderer classes.. and ideas?

thanks
zero - 29 Nov 2005 17:58 GMT
"tiewknvc9" <aotemp@hotmail.com> wrote in news:1133274793.353121.112970
@o13g2000cwo.googlegroups.com:

> Hi!
>
[quoted text clipped - 11 lines]
>
> thanks

If I'm not mistaken (but don't shoot me if I am) the default cell renderer
for plain text is a JLabel (or a subclass of it), and the editor is a
JTextField (again, or a subclass).  If that is indeed so, you could
override JTable:getCellRenderer and JTable:getCellEditor - you wouldn't
need to create your own renderer/editor.

public TableCellRenderer getCellRenderer(...)
{
  TableCellRenderer renderer = super.getCellRenderer(..);
  renderer.setFont(new Font(...));
  return renderer;
}

Without looking at the JTable source I'm not sure if you should override
getRowHeight as well.  I'm guessing no, it probably just returns the height
of the heighest component in the row.

Signature

Beware the False Authority Syndrome



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



©2009 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.