• 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
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

JTextArea Editor in JTable

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I want cells in JTable that takes multiline text. I have created two classes ,TextAreaEditor and TextAreaRenderer.I think there is a problem with TextAreaEditor class .When I type in one cell and go to other cell, conetent of previous cell disappears.
Cananybody help me out.
I have written the code as follows:
[code] class TextAreaEditor extends DefaultCellEditor {
protected JTextArea txt;
private String label;
public TextAreaEditor(JCheckBox checkBox) {
super(checkBox);
txt = new JTextArea();
txt.setOpaque(true);
txt.setLineWrap(true);
txt.setWrapStyleWord(true);
txt.setOpaque(true);

}
public Component getTableCellEditorComponent(JTable table, Object value,boolean isSelected, int row, int column) {

label = (value ==null) ? "" : value.toString();
txt.setText( label );
return txt;
}
public Object getCellEditorValue() {
return new String( label ) ;
}
public boolean stopCellEditing() {
return super.stopCellEditing();
}
protected void fireEditingStopped() {
super.fireEditingStopped();
}
}[\code]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic