public void adjustmentValueChanged(AdjustmentEvent event){ if (event.getSource() == ColScrollBar) { String temp = ""; ColTextField.setText(temp.valueOf(999-ColScrollBar.getValue())); DefaultTableModel DTM = (DefaultTableModel)Tabelle.getModel(); DTM.setColumnCount(999-ColScrollBar.getValue()); Tabelle.setModel(DTM); } if (event.getSource() == RowScrollBar) { String temp = ""; RowTextField.setText(temp.valueOf(999-RowScrollBar.getValue())); DefaultTableModel DTM = (DefaultTableModel)Tabelle.getModel(); DTM.setRowCount(999-RowScrollBar.getValue()); Tabelle.setModel(DTM); }}
public String getText(){ int x = 999-ColScrollBar.getValue(); int y = 999-RowScrollBar.getValue(); StringBuffer strBuf = new StringBuffer(); strBuf.append("<table>\n"); for (int i=0; i<y; ++i) { strBuf.append(" <tr>\n"); for (int l=0; l<x; ++l) { String value = (String)Tabelle.getValueAt(l,i); if (value == null) { value = ""; } strBuf.append(" <td>"+value+"</td>\n"); } strBuf.append(" </tr>\n"); } strBuf.append("</table>"); return strBuf.toString();}
ArrayIndexOutOfBoundsException: 4 >= 4