Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > jtable text size

Reply
Thread Tools

jtable text size

 
 
tiewknvc9
Guest
Posts: n/a
 
      11-29-2005
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

 
Reply With Quote
 
 
 
 
zero
Guest
Posts: n/a
 
      11-29-2005
"tiewknvc9" <(E-Mail Removed)> wrote in news:1133274793.353121.112970
@o13g2000cwo.googlegroups.com:

> 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
>


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.

--
Beware the False Authority Syndrome
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Preferred Size, Minimum Size, Size Jason Cavett Java 5 05-25-2008 08:32 AM
Putting a JTable inside a JTable cell? Tivo Escobar Java 1 04-12-2007 11:09 AM
How to move data from a CSV file to a JTable, and from a JTable to a CSV file ? Tintin92 Java 1 02-14-2007 06:51 PM
mega pixels, file size, image size, and print size - Adobe Evangelists Frank ess Digital Photography 0 11-14-2006 05:08 PM
Controlling JComboBox size in JTable cell Yulia Java 1 07-04-2005 10:29 AM



Advertisments