Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #165
| From | "alex" <alex@THRWHITE.remove-dii-this> |
|---|---|
| Subject | Re: jtable row height pro |
| Message-ID | <1164341674.384788.82360@j72g2000cwa.googlegroups.com> (permalink) |
| Newsgroups | comp.lang.java.gui |
| References | <q3ssl2940i5v585r9mtd46b7falllignp7@4ax.com> |
| Date | 2011-04-27 15:25 +0000 |
| Organization | TDS.net |
To: comp.lang.java.gui
> This almost worked, the row now becomes heigh enough to hold the whole
> text BUT the cell is always rendered with an empty line at the top,
> which means the last line is not visible. Any suggestions on how to
> fix this?
I'v faced the similar problem. When i put the html-text into table cell
which is using the DefaultTableCellRenderer (or my own JLabel-based
renderer), the displayed text begins from the the center of the cell,
with an empty space above it. Further, when the user manually resize
the column, the text aligns correctly. I've made an assumption, that
when JTable renders its cells for the first time, it doesn't take into
account the height of the cell. Row height is set in my program by
using the JTable.setRowHeight(int) method and is equal to all rows of
the table.
I spend three hours trying to solve a problem, and finally solve it by
put a JTable.setRowHeight(int) command into a
getTableCellRendererComponent() method of my renderer. So I think that
doing so is forcing the table to set row height at each render
operation. Looks ugly, but it works. So my renderer is looks in the
followng way:
private class MyRenderer extends DefaultTableCellRenderer {
public Component getTableCellRendererComponent(...) {
super.getTableCellRendererComponent(...);
table.setRowHeight(55);
return this;
}
}
---
* Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24
Back to comp.lang.java.gui | Previous | Next — Previous in thread | Next in thread | Find similar
jtable row height problem "Daniel" <daniel@THRWHITE.remove-dii-this> - 2011-04-27 15:25 +0000 Re: jtable row height pro "alex" <alex@THRWHITE.remove-dii-this> - 2011-04-27 15:25 +0000 Re: jtable row height pro "alex" <alex@THRWHITE.remove-dii-this> - 2011-04-27 15:25 +0000
csiph-web