public StringSelection getStringSelection() {
    StringSelection         result;
    int[]                   indices;
    int                     i;
    int                     n;
    StringBuffer            tmp;
    
    result = null;
    
    // nothing selected? -> all
    if (getSelectedRow() == -1) {
      // really?
      if (ComponentHelper.showMessageBox(
            getParent(),
            "Question...",
            "Do you really want to copy the whole table?",
            JOptionPane.YES_NO_OPTION,
            JOptionPane.QUESTION_MESSAGE ) != JOptionPane.YES_OPTION)
        return result;
      
      indices = new int[getRowCount()];
      for (i = 0; i < indices.length; i++)
        indices[i] = i;
    }
    else {
      indices = getSelectedRows();
    }
    
    // get header
    tmp = new StringBuffer();
    for (i = 0; i < getColumnCount(); i++) {
      if (i > 0)
        tmp.append("\t");
      tmp.append(getPlainColumnName(i));
    }
    tmp.append("\n");
    
    // get content
    for (i = 0; i < indices.length; i++) {
      for (n = 0; n < getColumnCount(); n++) {
        if (n > 0)
          tmp.append("\t");
        tmp.append(getValueAt(indices[i], n).toString());
      }
      tmp.append("\n");
    }
    
    result = new StringSelection(tmp.toString());
    
    return result;
  }