Java JTable Cell getContent(JTable table, String lineBreak, String cellBreak, int columnCount, int rowCount, int[] selectedRowsCount, int[] selectedColumsCount)

Here you can find the source of getContent(JTable table, String lineBreak, String cellBreak, int columnCount, int rowCount, int[] selectedRowsCount, int[] selectedColumsCount)

Description

get Content

License

LGPL

Declaration

private static String getContent(JTable table, String lineBreak, String cellBreak, int columnCount,
            int rowCount, int[] selectedRowsCount, int[] selectedColumsCount) 

Method Source Code


//package com.java2s;
//License from project: LGPL 

import java.util.logging.Logger;

import javax.swing.JTable;

public class Main {
    private static Logger logger = Logger.getLogger("uk.ac.starlink.splat.util.JTableUtilities");

    private static String getContent(JTable table, String lineBreak, String cellBreak, int columnCount,
            int rowCount, int[] selectedRowsCount, int[] selectedColumsCount) {

        if (columnCount > 0 && rowCount > 0) {
            StringBuffer value = new StringBuffer();

            for (int i = 0; i < rowCount; i++) {
                for (int j = 0; j < columnCount; j++) {
                    value.append(escapeContentBreaks(table.getValueAt(selectedRowsCount[i], selectedColumsCount[j]),
                            lineBreak, cellBreak));
                    if (j < columnCount - 1) {
                        value.append(cellBreak);
                    }/*w  w w.  j  a v a2  s  .com*/
                }
                value.append(lineBreak);
            }

            return value.toString();
        } else {
            logger.warning("Invalid selection.");
            return null;
        }
    }

    private static String escapeContentBreaks(Object cell, String lineBreak, String cellBreak) {
        return cell == null ? "" : cell.toString().replace(lineBreak, " ").replace(cellBreak, " ");
    }
}

Related

  1. copyCells(JTable table)
  2. defaultTableCellSize()
  3. getCellBounds(JTable table, int top, int bottom)
  4. getCellRectangle(JTable table, int row, int column)
  5. getColumnNames(JTable table, String lineBreak, String cellBreak)
  6. getCurrentSelectionContent(JTable table, String lineBreak, String cellBreak)
  7. getIntercellWidth(JTable table)
  8. getTableFocusCellForeground()
  9. getWidestCellInColumn(JTable table, TableColumn col)