Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #135

jtable row height problem

From "Daniel" <daniel@THRWHITE.remove-dii-this>
Subject jtable row height problem
Message-ID <q3ssl2940i5v585r9mtd46b7falllignp7@4ax.com> (permalink)
Newsgroups comp.lang.java.gui
Date 2011-04-27 15:25 +0000
Organization TDS.net

Show all headers | View raw


  To: comp.lang.java.gui
Hello all, 
I have a problem with a jtable. I have written a program to simplify
the translation of the texts in my main application. So basically what
happen is that my editor reads the .properties file and lets the user
change the values of them. 

The problem comes when the user is trying to view a value with html
text in it. What happened was that the html formatting contained
linebreaks and the default table cell renderer did the linebreaks BUT
the height of the cell did not update so all you could see was the
bottom of the first line and the top of the second. 

I tried to fix this by using my own cell renderer that adjusted the
height if the preferred height of the renderer was greater than the
height of the row.
 
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 will try to make a minimal code example during the weekend.
I post the code for the cell renderer as it is short and possibly
(even probably) the cause of the problem


public class CellRenderer extends DefaultTableCellRenderer {

 public Component getTableCellRendererComponent(JTable table, Object
value, boolean isSelected, boolean hasFocus, int row, int column) {

        Component c=
super.getTableCellRendererComponent(table,value,isSelected,hasFocus,row,column);

       if(table.getRowHeight(row)<c.getPreferredSize().height){
             table.setRowHeight(row,    

c.getPreferredSize().height+table.getRowMargin());
         }


        return
super.getTableCellRendererComponent(table,value,isSelected,hasFocus,row,column);
    }
}

cheers
Daniel

---
 * 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 | NextNext in thread | Find similar


Thread

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