• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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]
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic