• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Multilines in JTable.

 
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Qunfeng Wang
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Still have some problem.I can't get the max heigt for a specific row.
 
Qunfeng Wang
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
ice is for people that are not already cool. Chill with this tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic