private void tableSetData() {
String[] columnNames = new String[week.length];
columnNames[0] = "Name";
columnNames[1] = "Projekt";
for(int i = 2; i < columnNames.length; i++){
columnNames[i] = week[i-2];
}
//int nTablelength = table.length;
String[][] data = new String[0][columnNames.length];
c_initData = InitData.fl;
setDtm(new DefaultTableModel(data, columnNames){
/**Eigenes DefaultTableModel um nur Zahlen auf der Tabelle
* nach Zeile 2 zu zulassen.
*/
private static final long serialVersionUID = 1L;
@Override
public void setValueAt(Object aValue, int row, int col)
{
// Abbruch wenn der Wert kein Integer ist.
if (aValue instanceof Integer)
{
//Abbruch wenn der Wert nicht zwischen 0 - 100 liegt.
int value = ((Integer)aValue).intValue();
if(value < 0 || value > 100){
return;
}
}
// Setze den Wert.
super.setValueAt(aValue, row, col);
}
@Override
public Class<?> getColumnClass(int col)
{
if (col >=2)
return Integer.class;
else{
return String.class;
}
}
});
Vector<Vector<String>> filler = c_initData.get2DTable();
Vector<String> formatedVector = new Vector<String>();
for(int i = 1; i < filler.size(); i++){
formatedVector = filler.get(i);
int z = filler.get(i).size()-1;
int gewollteKalenderwoche = c_initData.getWeekNow() + c_initData.getAnzahlWeeks();
// System.out.println(gewollteKalenderwoche);
while(z >= gewollteKalenderwoche-1){
formatedVector.remove(z);
z--;
}
int k = c_initData.getWeekNow();
// System.out.println(k);
while(k >= 2){
try{
formatedVector.remove(k);
}catch(ArrayIndexOutOfBoundsException ex){
}
k--;
}
// System.out.println("Something: "+formatedVector);
dtm.addRow(formatedVector);
}
jTable = new GroupingTable(dtm, 0);
jTable.setLayout(null);
//c_TableM.save();
jTable.setRowHeight(jTable.getRowHeight());
jTable.setAutoCreateRowSorter(true);
jTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
for (int i = 0; i < dtm.getRowCount(); i++) {
jTable.getRowSorter().convertRowIndexToModel(i);
}
//ComboBoxen werden auf das JTable gelegt.
TableColumn tColumnNames = jTable.getColumnModel().getColumn(0);
comboBox_names = new JComboBox();
TableColumn tColumnProjekts = jTable.getColumnModel().getColumn(1);
comboBox_projekts = new JComboBox();
jTable.addMouseListener(this);
//ComboxBox f�r Namen und Projekte werden mit den Namen und Projekten gef�llt.
comboBox_names.addItem("");
comboBox_projekts.addItem("");
for(int i = 0; i < namen.length; i++){
comboBox_names.addItem(namen[i]);
}
for(int i = 0; i < projekt.length; i++){
comboBox_projekts.addItem(projekt[i]);
}
//CellEditor f�r die ComboBoxen.
tColumnNames.setCellEditor(new DefaultCellEditor(comboBox_names));
tColumnProjekts.setCellEditor(new DefaultCellEditor(comboBox_projekts));
// Neuer ColoredTableCellRenderer f�r die Einf�rbung der Tabellen.
// DefaultTableCellRenderer renderer =
// new CustomTableCellRenderer ();
// tColumnNames.setCellRenderer(renderer);
// tColumnProjekts.setCellRenderer(renderer);
// jTable.setDefaultRenderer(this.getClass(), new CustomTableCellRenderer());
//ModelListener f�r die Tabelle um %te an Zahlen zu erg�nzen
getDtm().addTableModelListener(this);
//c_TableM.getNotFull();
jTable.setFillsViewportHeight(true);
jTable.getTableHeader().setOpaque(true);
jTable.getTableHeader().setResizingAllowed(true);
for (int i = 0; i < jTable.getColumnCount(); i++) {
TableColumn col = jTable.getColumnModel().getColumn(i);
col.setPreferredWidth(70);
}
Dimension size2 = jTable.getPreferredScrollableViewportSize();
jTable.setPreferredScrollableViewportSize
(new Dimension(getSize().width, size2.height));
jTable.getTableHeader().setBounds(0, 0, jTable.getPreferredSize().width, 0);
jTable.getTableHeader().setReorderingAllowed(false);
jScrollPane.setViewportView(jTable);
}