aspose file tools
The moose likes Swing / AWT / SWT and the fly likes Multilines in JTable. Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "Multilines in JTable." Watch "Multilines in JTable." New topic
Author

Multilines in JTable.

qunfeng wang
Ranch Hand

Joined: Jan 28, 2005
Posts: 407
I use a cellrender found at this froum:

javax.swing.*;
import java.awt.*;
import javax.swing.table.TableCellRenderer;

class MultiLineHeaderRenderer extends JTextArea implements TableCellRenderer{
MultiLineHeaderRenderer(){
setOpaque(true);
setLineWrap(true);
setWrapStyleWord(true);
}

public Component getTableCellRendererComponent(JTable table,
Object value,
boolean isSelected,
boolean hasFocus,
int row,int column){
setFont(new Font("Dialog",1,11));
setText(value.toString());
//setBorder( UIManager.getBorder("TableHeader.cellBorder") );
return this;
}
}

Then I set my table cellrender to this.It does work when I setRowHeight(height) properly. I know there is the last straw,so I can set the row height according to the JTextArea's height. Maybe I've knowen how to do that.


To be or not to be. It's a question.
qunfeng wang
Ranch Hand

Joined: Jan 28, 2005
Posts: 407

Still have some problem.I can't get the max heigt for a specific row.
qunfeng wang
Ranch Hand

Joined: Jan 28, 2005
Posts: 407
For a specific row, I get the max height cell,then setRowHeight().
But this is an awful thing,isn't it?
Some one give me a smart way?
Thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Multilines in JTable.
 
Similar Threads
JTable ........
JTable
Related JTable Header
JTable
JTable