Java Code Examples for javax.swing.JTable

The following examples show how to use javax.swing.JTable. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
public static void initializeTable(JTable table)
{
	table.setAutoCreateColumnsFromModel(false);
	JTableHeader header = table.getTableHeader();
	TableColumnModel columns = new DefaultTableColumnModel();
	TableCellRenderer headerRenderer = header.getDefaultRenderer();
	columns.addColumn(Utilities.createTableColumn(0, "in_level", headerRenderer, false));
	columns.addColumn(Utilities.createTableColumn(1, "in_class", headerRenderer, true));
	TableColumn remainCol = Utilities.createTableColumn(2, "in_iskRemain", headerRenderer, false);
	remainCol.setCellRenderer(new BoldNumberRenderer());
	columns.addColumn(remainCol);
	columns.addColumn(Utilities.createTableColumn(3, "in_gained", headerRenderer, false));
	table.setDefaultRenderer(Integer.class, new TableCellUtilities.AlignRenderer(SwingConstants.CENTER));
	table.setColumnModel(columns);
	table.setFocusable(false);
	header.setReorderingAllowed(false);
	header.setResizingAllowed(false);
}
 
Example 2
Source Project: mts   Source File: JTableLogs.java    License: GNU General Public License v3.0 6 votes vote down vote up
public void collapseCell(int selected) {
    final JTable _this = this;
    //if(lastSelected == selected)
    {
        if (_this.getRowHeight(selected) != _this.getRowHeight()) {
            _this.setRowHeight(selected, _this.getRowHeight());
        }
        else {
            int maxHeight = _this.getRowHeight();
            for (int i = 0; i < _this.getColumnCount(); i++) {
                Component component = _this.getCellRenderer(selected, i).getTableCellRendererComponent(_this, _this.getValueAt(selected, i), false, true, selected, i);
                int height = (int) component.getPreferredSize().getHeight();

                maxHeight = height > maxHeight ? height : maxHeight;
            }
            _this.setRowHeight(selected, maxHeight);
        }
    }

    //lastSelected = selected;
}
 
Example 3
Source Project: OpERP   Source File: ListCategoryPane.java    License: MIT License 6 votes vote down vote up
public ListCategoryPane() {
	pane = new JPanel(new MigLayout("fill"));

	table = new JTable();
	table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	table.addMouseListener(new MouseAdapter() {
		@Override
		public void mousePressed(MouseEvent e) {
			if (SwingUtilities.isLeftMouseButton(e)
					&& e.getClickCount() == 2
					&& table.getSelectedRow() != -1) {

				Category category = tableModel.getRow(table
						.getSelectedRow());

				categoryDetailsPane.show(category, getPane());
			}
		}
	});

	final JScrollPane scrollPane = new JScrollPane(table,
			JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
			JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);

	pane.add(scrollPane, "grow");
}
 
Example 4
@Override
public boolean importData(TransferHandler.TransferSupport info) {
    JTable target = (JTable) info.getComponent();
    JTable.DropLocation dl = (JTable.DropLocation) info.getDropLocation();
    int dropIndex = dl.getRow();
    int max = table.getModel().getRowCount();
    if (dropIndex < 0 || dropIndex > max) {
        dropIndex = max;
    }
    target.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    try {
        Integer rowFrom = (Integer) info.getTransferable().getTransferData(localObjectFlavor);
        if (rowFrom != -1 && rowFrom != dropIndex) {
            ((Reorderable)table.getModel()).reorder(rowFrom, dropIndex);
            if (dropIndex > rowFrom) {
                dropIndex--;
            }
            target.getSelectionModel().addSelectionInterval(dropIndex, dropIndex);
            return true;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return false;
}
 
Example 5
private void createLicensesPanel() {
    JLabel infoText = new JLabel("<html>"
                                 + "<b>The table below gives an overview of all 3rd-party licenses used by SNAP "
                                 + "and the ESA Toolboxes.<br>"
                                 + "The dependencies of other plugins are not considered in this list.</b>"
    );

    JComponent licensesComponent;
    Path licensesFile = getApplicationHomeDir().toPath().resolve(THIRD_PARTY_LICENSE_DEFAULT_FILE_NAME);
    try {
        JTable table = createLicensesTable(licensesFile);
        licensesComponent = createScrollPane(table);
    } catch (IOException e) {
        String msg = "Error: Cloud not read licenses from " + licensesFile.toAbsolutePath().toString();
        LOG.log(Level.WARNING, msg, e);
        JLabel msgLabel = new JLabel(msg);
        msgLabel.setVerticalAlignment(SwingConstants.TOP);
        licensesComponent = msgLabel;
    }


    add(infoText, BorderLayout.NORTH);
    add(licensesComponent, BorderLayout.CENTER);

    setVisible(true);
}
 
Example 6
Source Project: nullpomino   Source File: NetAdmin.java    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Copy the selected row to clipboard
 * @param table JTable
 */
private static void copyTableRowToClipboard(final JTable table) {
	int row = table.getSelectedRow();

	if(row != -1) {
		String strCopy = "";

		for(int column = 0; column < table.getColumnCount(); column++) {
			Object selectedObject = table.getValueAt(row, column);
			if(selectedObject instanceof String) {
				if(column == 0) {
					strCopy += (String)selectedObject;
				} else {
					strCopy += "," + (String)selectedObject;
				}
			}
		}

		StringSelection ss = new StringSelection(strCopy);
		Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
		clipboard.setContents(ss, ss);
	}
}
 
Example 7
@Override
protected void initComponents() {
    final AbstractButton switchToChartButton = ToolButtonFactory.createButton(iconForSwitchToChartButton, false);
    switchToChartButton.setToolTipText("Switch to Chart View");
    switchToChartButton.setName("switchToChartButton");
    switchToChartButton.setEnabled(hasAlternativeView());
    switchToChartButton.addActionListener(e -> showAlternativeView());

    final JPanel buttonPanel = new JPanel(new BorderLayout());
    buttonPanel.add(switchToChartButton, BorderLayout.NORTH);
    buttonPanel.add(getHelpButton(), BorderLayout.SOUTH);

    add(buttonPanel, BorderLayout.EAST);

    table = new JTable();
    table.removeEditor();
    table.setGridColor(Color.LIGHT_GRAY.brighter());
    table.addMouseListener(new PagePanel.PopupHandler());
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

    final JScrollPane scrollPane = new JScrollPane(table);

    add(scrollPane, BorderLayout.CENTER);
}
 
Example 8
Source Project: zencash-swing-wallet-ui   Source File: TransactionsDetailPanel.java    License: MIT License 6 votes vote down vote up
private JTable createTransactionsTable(String rowData[][])
	throws WalletCallException, IOException, InterruptedException
{
	String columnNames[] = langUtil.getString("transactions.detail.panel.column.names").split(":");
       JTable table = new TransactionTable(
       	rowData, columnNames, this.parentFrame, this.clientCaller, this.installationObserver); 
       table.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
       table.getColumnModel().getColumn(0).setPreferredWidth(190);
       table.getColumnModel().getColumn(1).setPreferredWidth(145);
       table.getColumnModel().getColumn(2).setPreferredWidth(170);
       table.getColumnModel().getColumn(3).setPreferredWidth(210);
       table.getColumnModel().getColumn(4).setPreferredWidth(405);
       table.getColumnModel().getColumn(5).setPreferredWidth(800);

       return table;
}
 
Example 9
Source Project: Repeat   Source File: SwingUtil.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Show a list of values to user
 * @param titles titles of the values
 * @param values list of values in the according order of the titles
 */
public static void showValues(String[] titles, String[] values) {
	if (titles.length == 0 || (titles.length != values.length)) {
		return;
	}

	JTable table = new JTable();
	table.setModel(new DefaultTableModel(
		new Object[][] {},
		new String[] {" ", " "}
	));
	SwingUtil.TableUtil.ensureRowNumber(table, titles.length);

	for (int i = 0; i < titles.length; i++) {
		table.setValueAt(titles[i], i, 0);
		table.setValueAt(values[i], i, 1);
	}
	JScrollPane mainPanel = new JScrollPane(table);

	JOptionPane.showMessageDialog(null, mainPanel,
			"Enter values", JOptionPane.OK_OPTION);
}
 
Example 10
Source Project: pgptool   Source File: MainFrameView.java    License: GNU General Public License v3.0 6 votes vote down vote up
private JScrollPane initTableComponent() {
	table = new JTable();

	// Adjust some visual appearence
	table.setRowHeight(22);

	// Add listeners
	selectionModel = new DefaultListSelectionModel();
	selectionModel.setSelectionMode(DefaultListSelectionModel.SINGLE_SELECTION);
	selectionModel.addListSelectionListener(rowSelectionListener);
	table.setSelectionModel(selectionModel);
	table.addMouseListener(listMouseListener);
	table.setDefaultRenderer(EncryptBackAction.class, new EncryptBackActionCellRenderer());
	table.addMouseListener(encrBackClickHandler);
	initTableKeyListener();

	// Envelope in scrollpane
	scrollPane = new JScrollPane();
	scrollPane.addMouseListener(listMouseListener);
	scrollPane.setViewportView(table);
	return scrollPane;
}
 
Example 11
/**
 * Gets the table cell editor component.
 *
 * @param table the table
 * @param value the value
 * @param isSelected the is selected
 * @param row the row
 * @param column the column
 * @return the table cell editor component
 */
@Override
public Component getTableCellEditorComponent(
        JTable table, Object value, boolean isSelected, int row, int column) {

    ProcessFunctionParameterValue currentValue = tableModel.getValue(row);

    if (currentValue.isOptional()) {
        selectedIndex = row;
        currentEditor = checkBox;
        checkBox.setSelected(currentValue.isIncluded());
        return checkBox;
    } else {
        selectedIndex = -1;
        currentEditor = null;
    }

    return null;
}
 
Example 12
/**
 * Returns the rendered header cell for the supplied value and column.
 *
 * @param jtSystemProperties The JTable
 * @param value The value to assign to the cell
 * @param bIsSelected True if cell is selected
 * @param iRow The row of the cell to render
 * @param iCol The column of the cell to render
 * @param bHasFocus If true, render cell appropriately
 * @return The rendered cell
 */
@Override
public Component getTableCellRendererComponent(JTable jtSystemProperties, Object value, boolean bIsSelected,
    boolean bHasFocus, int iRow, int iCol)
{
	// Get header renderer
	JLabel header = (JLabel) jtSystemProperties.getColumnModel().getColumn(iCol).getHeaderRenderer();

	// The headers contain left-aligned text
	header.setText(value.toString());
	header.setHorizontalAlignment(LEFT);

	header.setBorder(new CompoundBorder(new BevelBorder(BevelBorder.RAISED), new EmptyBorder(0, 5, 0, 5)));

	return header;
}
 
Example 13
public Component getTableCellEditorComponent(JTable table,
                                             Object value,
                                             boolean isSelected,
                                             int row,
                                             int column) {
    String className;
    if (table instanceof XTable) {
        XTable mytable = (XTable) table;
        className = mytable.getClassName(row);
    } else {
        className = String.class.getName();
    }
    try {
        init(value,Utils.getClass(className));
    }
    catch(Exception e) {}

    return this;
}
 
Example 14
Source Project: netbeans   Source File: TaskListTable.java    License: Apache License 2.0 6 votes vote down vote up
@Override
        public Component getTableCellRendererComponent(JTable table, Object value,
                              boolean isSelected, boolean hasFocus, int row, int column) {
            
            if( getFoldingModel().isGroupRow( row ) ) {
//                hasFocus = table.isFocusOwner() && isSelected;
            }
            Component res = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
            if( res instanceof JLabel ) {
                if( value instanceof FoldingTaskListModel.FoldingGroup ) {
                    FoldingTaskListModel.FoldingGroup fg = (FoldingTaskListModel.FoldingGroup)value;
                    JLabel renderer = (JLabel)res;
                    renderer.setText( fg.getGroup().getDisplayName() + " ("+fg.getTaskCount()+")" );
                    Icon treeIcon = fg.isExpanded() ? openedIcon : closedIcon;
                    renderer.setIcon( treeIcon );
                    renderer.setToolTipText( fg.getGroup().getDescription() );
                    renderer.setHorizontalAlignment( JLabel.LEFT );
                    if( !isSelected )
                        renderer.setBackground( getBackgroundColor() );
                }
            }
            return res;
        }
 
Example 15
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row,
	int column)
{
	boolean selected = false;
	if (value instanceof Boolean)
	{
		selected = (Boolean) value;
	}
	else if (value instanceof String)
	{
		selected = value.equals("true");
	}
	button.setSelected(selected);
	return button;
}
 
Example 16
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
		int row, int column) {
	// TODO Auto-generated method stub
	final Component cellComponent =  super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
	
	if(isSelected || hasFocus) {
		
		cellComponent.setBackground(Color.decode("#10d6d1"));
	}
	
	else {
		
		cellComponent.setBackground(row % 2 == 0 ? table.getSelectionBackground() : table.getBackground());
	}
	
	return cellComponent;
}
 
Example 17
@Override
public Component getTableCellRendererComponent(JTable table, Object value,
        boolean isSelected, boolean hasFocus, int row, int column) {
  if(value instanceof Icon) {
    super.getTableCellRendererComponent(table, "", isSelected, hasFocus,
            row, column);
    setIcon((Icon)value);

    if (value instanceof MavenIcon)
  	  setToolTipText("Maven Plugin");
    else if (value instanceof OpenFileIcon)
  	  setToolTipText("Directory Plugin");
    else if (value instanceof InvalidIcon)
  	  setToolTipText("Invalid Plugin");

    return this;
  } else {
    return super.getTableCellRendererComponent(table, value, isSelected,
            hasFocus, row, column);
  }
}
 
Example 18
Source Project: netbeans   Source File: ComboBoxTableCellEditor.java    License: Apache License 2.0 6 votes vote down vote up
/**********************************************************************
    *  Is the cell editable? If the mouse was pressed at a margin
    *  we don't want the cell to be editable.
    *
    *  @param  evt  The event-object.
    *
    *  @interfaceMethod javax.swing.table.TableCellEditor
    *********************************************************************/

public boolean isCellEditable (EventObject evt)
{

       this.startEditingEvent = evt;
       if  (evt instanceof MouseEvent  &&  evt.getSource () instanceof JTable)
       {
           MouseEvent me = (MouseEvent) evt;
           JTable table = (JTable) me.getSource ();
           Point pt = new Point (me.getX (), me.getY ());
           int row = table.rowAtPoint (pt);
           int col = table.columnAtPoint (pt);
           Rectangle rec = table.getCellRect (row, col, false);
           if  (me.getY () >= rec.y + rec.height  ||  me.getX () >= rec.x + rec.width)
           {
               return false;
           }
       }

       return super.isCellEditable (evt);

}
 
Example 19
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
                                               int row, int column) {

    if (value != null) {
        setSelected((Boolean) value);
    } else {
        setSelected(false);
    }
    if (isSelected) {
        setBackground(initializer.getConfiguration().getDefaultListSelectionBackground());
        setForeground(initializer.getConfiguration().getDefaultListSelectionForeground());
    } else {
        setBackground(initializer.getConfiguration().getDefaultListNonSelectionBackground());
        setForeground(initializer.getConfiguration().getDefaultListNonSelectionForeground());
    }
    return this;
}
 
Example 20
Source Project: jdal   Source File: BooleanRenderer.java    License: Apache License 2.0 6 votes vote down vote up
public Component getTableCellRendererComponent(JTable table, Object value,
		boolean isSelected, boolean hasFocus, int row, int column) {
	if (isSelected) {
		setForeground(table.getSelectionForeground());
		super.setBackground(table.getSelectionBackground());
	}
	else {
		setForeground(table.getForeground());
		setBackground(table.getBackground());
	}
	setSelected((value != null && ((Boolean)value).booleanValue()));

	if (hasFocus) {
		setBorder(UIManager.getBorder("Table.focusCellHighlightBorder"));
	} else {
		setBorder(noFocusBorder);
	}

	return this;
}
 
Example 21
Source Project: jplag   Source File: AdminTool.java    License: GNU General Public License v3.0 5 votes vote down vote up
public Component getTableCellRendererComponent(JTable table, Object obj, boolean isSelected, boolean hasFocus, int row, int coloumn) {
	String str = "";
	if (obj != null)
		str = obj.toString();
	setBackground(isSelected ? VERYLIGHTRED : LIGHTRED);

	if (hasFocus) {
		if (badFocusBorder == null)
			badFocusBorder = BorderFactory.createLineBorder(LIGHTRED, 2);
		setBorder(badFocusBorder);
	} else
		setBorder(null);
	setText(str);
	return this;
}
 
Example 22
Source Project: hottub   Source File: XTable.java    License: GNU General Public License v2.0 5 votes vote down vote up
public XTable () {
    super();
    @SuppressWarnings("serial")
    final TableSorter sorter = new TableSorter();
    setModel(sorter);
    sorter.addMouseListenerToHeaderInTable(this);
    setRowSelectionAllowed(false);
    setColumnSelectionAllowed(false);
    setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
}
 
Example 23
Source Project: javamoney-examples   Source File: CategoryTotalTable.java    License: Apache License 2.0 5 votes vote down vote up
public
Component
getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
    boolean hasFocus, int row, int column)
{
  // Customize look.
  setLookFor(this, row, isSelected);

  setToolTipText(buildTooltipText(row));

  // Text.
  if(get(row).getType().isSummary() == true)
  {
    setText("<html><b>" + value.toString() + "</b></html>");
  }
  else
  {
    setText(value.toString());
  }

  // Alignment.
  if(column == ROW_COLUMN)
  {
    setHorizontalAlignment(SwingConstants.CENTER);
  }
  else if(column == CATEGORY_COLUMN || column == GROUP_COLUMN)
  {
    setHorizontalAlignment(SwingConstants.LEFT);
  }
  else
  {
    setHorizontalAlignment(SwingConstants.TRAILING);
  }

  return this;
}
 
Example 24
@Override
public boolean importData(TransferHandler.TransferSupport support) {
    if (!canImport(support)) {
        return false;
    }
    JTable.DropLocation dl = (JTable.DropLocation) support.getDropLocation();
    JTable table = (JTable) support.getComponent();
    int row = dl.getRow();
    int column = dl.getColumn();

    if (row == -1) {
        return false;
    }

    if (dropObject instanceof ObjectRepDnD) {
        switch (column) {
            case inputColumn:
                putInput(table, row);
                break;
            case conditionColumn:
                putRelativeObject(table, row);
                break;
            default:
                putWebObjects(table, row);
                break;
        }

    } else if (dropObject instanceof TestDataDetail) {
        putTestData(table, row);
    } else if (dropObject instanceof TestCaseDnD) {
        putReusables(table, row);
    } else {
        return false;
    }
    return super.importData(support);
}
 
Example 25
Source Project: littleluck   Source File: OscarCellRenderers.java    License: Apache License 2.0 5 votes vote down vote up
public Component getTableCellRendererComponent(JTable table, Object value,
        boolean isSelected, boolean hasFocus, int row, int column) {
    super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
    setText(value != null ? value.toString() : "unknown");
    if (!isSelected) {
        setBackground(rowColors[row % rowColors.length]);
    }
    
    setBorder(null);
    return this;
}
 
Example 26
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
		int row, int column) {

	final Component cellComponent = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row,
			column);

	String colrowVal = String.valueOf(value);

	if(isSelected || hasFocus) {
		cellComponent.setBackground(Color.decode("#10d6d1"));
	}
	
	else {
		
		if(column == 0) {
			cellComponent.setBackground(Color.decode("#effbad"));
		}
		
		else if (colrowVal.equalsIgnoreCase("CLEAN")) {
			cellComponent.setBackground(Color.decode("#afe2fb"));
		}

		else if (colrowVal.equalsIgnoreCase("DIRTY")) {
			cellComponent.setBackground(Color.decode("#d24760"));
		}

		else if(colrowVal.equalsIgnoreCase("DND")) {
			cellComponent.setBackground(Color.decode("#ffc300"));
		}
		
		else {
			cellComponent.setBackground(Color.decode("#f4a0c4"));
		}

	}

	return cellComponent;
}
 
Example 27
Source Project: seaglass   Source File: SeaGlassTableUI.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * DOCUMENT ME!
 *
 * @param  table DOCUMENT ME!
 *
 * @return DOCUMENT ME!
 */
private static PropertyChangeListener createAncestorPropertyChangeListener(final JTable table) {
    return new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent event) {
            if (table.getParent() instanceof JViewport && table.getParent().getParent() instanceof JScrollPane) {
                table.getParent().repaint();
            }
        }
    };
}
 
Example 28
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
    boolean hasFocus, int row, int column) {


  if (value instanceof String[]) {
    setListData((String[]) value);
  }

  return this;
}
 
Example 29
Source Project: constellation   Source File: ColumnSelectPanel.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Constructor for the column selection panel.
 *
 * the parent window can be accessed
 *
 * @param table the table for the ColumnSelectPanel.
 */
public ColumnSelectPanel(final JTable table) {
    initComponents();
    availableColumnModel = new DefaultListModel<>();
    selectedColumnModel = new DefaultListModel<>();
    availableColumnList.setModel(availableColumnModel);
    selectedColumnList.setModel(selectedColumnModel);

    final SegAttrRenderer segAttrRenderer = new SegAttrRenderer();
    availableColumnList.setCellRenderer(segAttrRenderer);
    selectedColumnList.setCellRenderer(segAttrRenderer);

    selectAllButton.setText("");
    selectAllButton.setIcon(UserInterfaceIconProvider.CHEVRON_RIGHT_DOUBLE.buildIcon(16, ConstellationColor.BLACK.getJavaColor()));
    deselectAllButton.setText("");
    deselectAllButton.setIcon(UserInterfaceIconProvider.CHEVRON_LEFT_DOUBLE.buildIcon(16, ConstellationColor.BLACK.getJavaColor()));
    selectButton.setText("");
    selectButton.setIcon(UserInterfaceIconProvider.CHEVRON_RIGHT.buildIcon(16, ConstellationColor.BLACK.getJavaColor()));
    deselectButton.setText("");
    deselectButton.setIcon(UserInterfaceIconProvider.CHEVRON_LEFT.buildIcon(16, ConstellationColor.BLACK.getJavaColor()));
    moveDownButton.setText("");
    moveDownButton.setIcon(UserInterfaceIconProvider.CHEVRON_DOWN.buildIcon(16, ConstellationColor.BLACK.getJavaColor()));
    moveUpButton.setText("");
    moveUpButton.setIcon(UserInterfaceIconProvider.CHEVRON_UP.buildIcon(16, ConstellationColor.BLACK.getJavaColor()));
    setModelData(table);
    updateButtonStatus();
}
 
Example 30
Source Project: marathonv5   Source File: JTableJavaElement.java    License: Apache License 2.0 5 votes vote down vote up
public static String[][] getContent(JTable component) {
	int rows = component.getRowCount();
	int cols = component.getColumnCount();
	String[][] content = new String[rows][cols];
	for (int i = 0; i < rows; i++) {
		for (int j = 0; j < cols; j++) {
			Object valueAt = component.getValueAt(i, j);
			if (valueAt == null) {
				valueAt = "";
			}
			content[i][j] = valueAt.toString();
		}
	}
	return content;
}