public void CreateOutputPanel()
{
FlowLayout flowLayout = new FlowLayout();
flowLayout.setHgap(0);
JScrollPane scpCalc1 = new JScrollPane();
//fixierte Spalte erstellen = RowHeader
ListModel lm = new AbstractListModel() {
String headers[] = {"1", "2", "3", "4", "5", "6", "7", "8"};
public int getSize() { return headers.length; }
public Object getElementAt(int index) {
return headers[index];
}
};
// Spaltenname
Object[] columnName = new Object[]
{
"<html><font >T<sub>lim</sub>\n °C",
"<html><font >\u03B1<sub>B</sub>\n 1/K",
"<html><font >E<sub> </sub>\n N/mm²",
"<html><font >\u03C4<sub>s</sub>\n N/mm²",
"<html><font >\u03C3<sub>D</sub>\n N/mm²",
"f", "<html><font >f<sub>max</sub>",
"<html><font >P<sub>f</sub>\n W",
"<html><font >M<sub>f</sub>\n Nm",
"<html><font >T<sub> </sub>\n °C",
"<html><font >t<sub> </sub>\n h",
"<html><font >s<sub>D</sub>\n km",
"<html><font >t<sub>min</sub>\n h",
"<html><font >s<sub>D, min</sub>\n km",
"<html><font >C<sub>cold</sub>\n µm",
"<html><font >C<sub>warm</sub>\n µm"
};
// Array für Tabellendaten füllen
for (int i = 0; i < columnData.length; i++)
{
for (int j = 0; j < columnData[0].length; j++)
{
columnData[i][j] = new Double(0);
}
}
}
// TableModel erstellen, daß nicht editierbar ist
DefaultTableModel dtmProperties = new DefaultTableModel(columnData, columnName)
{
public boolean isCellEditable(int row, int col)
{
return false;
}
};
// Tabelle erstellen mit TableModel, RowHeader und GroupableTabelHeader
tblCalc1 = new JTable(dtmProperties)
{
protected JTableHeader createDefaultTableHeader()
{
return new GroupableTableHeader(columnModel);
}
};
// kein Resize der Tabelle
tblCalc1.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
//GroupableTableHeader
TableColumnModel cm = tblCalc1.getColumnModel();
ColumnGroup cgProperties = new ColumnGroup("Material Properties");
cgProperties.add(cm.getColumn(0));
cgProperties.add(cm.getColumn(1));
cgProperties.add(cm.getColumn(2));
cgProperties.add(cm.getColumn(3));
cgProperties.add(cm.getColumn(4));
ColumnGroup cgIteration = new ColumnGroup("Iteration");
cgIteration.add(cm.getColumn(5));
cgIteration.add(cm.getColumn(6));
cgIteration.add(cm.getColumn(7));
cgIteration.add(cm.getColumn(8));
cgIteration.add(cm.getColumn(9));
ColumnGroup cgLifetime = new ColumnGroup("Lifetime");
cgLifetime.add(cm.getColumn(10));
cgLifetime.add(cm.getColumn(11));
cgLifetime.add(cm.getColumn(12));
cgLifetime.add(cm.getColumn(13));
ColumnGroup cgClearance = new ColumnGroup("Clearance");
cgClearance.add(cm.getColumn(14));
cgClearance.add(cm.getColumn(15));
GroupableTableHeader header = (GroupableTableHeader)tblCalc1.getTableHeader();
header.addColumnGroup(cgProperties);
header.addColumnGroup(cgIteration);
header.addColumnGroup(cgLifetime);
header.addColumnGroup(cgClearance);
//Header in 2 Zeilen aufteilen
MultiHeaderRenderer renderer = new MultiHeaderRenderer();
Enumeration enum = tblCalc1.getColumnModel().getColumns();
while (enum.hasMoreElements())
{
((TableColumn)enum.nextElement()).setHeaderRenderer(renderer);
}
// RowHeader hinzufügen und Aussehen festlegen
JList rowHeader = new JList(lm);
rowHeader.setFixedCellWidth(50);
rowHeader.setFixedCellHeight(tblCalc1.getRowHeight());
rowHeader.setCellRenderer(new RowHeaderRenderer(tblCalc1));
//Tabelle ScrollPane hinzufügen und RowHeader für ScrollPane festlegen
scpCalc1.getViewport().add(tblCalc1, null);
scpCalc1.setRowHeaderView(rowHeader);
//ScrollPane in TabbeddPane einfügen
tpnOutput.add("Material Properties", scpCalc1);
sppMain.add(tpnOutput, JSplitPane.BOTTOM);
}