Bis jetzt habe ich in PHP und JavaScript entwickelt. Ich lerne gerade groovy, aber leider gibt es nicht viele Tutorials über diese Sprache und das Buch, das ich gerade lese (Groovy Recipes), enthält nichts über die Verwendung von Groovys Swingbuilder.Tabelle mit Groovy's Swing Builder
Als Projekt bei der Arbeit, würde Ich mag eine Tabelle wie das Schema unten erstellen:
Instancename
groupId artifactId DEV TEST PROD
firstgroup firstartifact 1.00 1.05 1.05
secondgroup secondartifact 2.02 2.00 2.00
Das ist mein aktueller Code ist:
import groovy.swing.SwingBuilder
import java.awt.BorderLayout
public class Gui {
public void createGui(String instanceTitle, ArrayList<Artifact> columnData){
def bldr = new groovy.swing.SwingBuilder();
def frame = bldr.frame(
title: "Overview",
size: [600,150],
defaultCloseOperation:javax.swing.WindowConstants.EXIT_ON_CLOSE
){
def tab = table(constraints:BorderLayout.CENTER) {
tableModel(list:columnData) {
propertyColumn(header:'GroupId', propertyName:'groupId')
propertyColumn(header:'ArtifactId', propertyName:'artifactId')
propertyColumn(header:'Dev', propertyName:'devVersion')
propertyColumn(header:'Test', propertyName:'testVersion')
propertyColumn(header:'Prod', propertyName:'prodVersion')
}
}
widget(constraints:BorderLayout.NORTH, tab.tableHeader)
}
frame.pack()
frame.show();
}
}
Als ich das laufen, ich bekomme Tabelle mit meinen Daten gefüllt. Meine Frage ist, wie kann ich "DEV", "TEST" und "PROD" "InstanceName" unterordnen? Ich weiß nicht, wie man einen Header über den anderen fügt. In html würde es so aussehen:
<table>
<tr>
<td colspan="2"></td>
<td colspan="3">Instancename</td>
</tr>
<tr>
<td>groupId</td>
<td>artifactId</td>
<td>DEV</td>
<td>TEST</td>
<td>PROD</td>
</tr>
<tr>
<td>firstgroupid</td>
<td>firstartifactid</td>
<td>firstdevversion</td>
<td>firsttestversion</td>
<td>firstprodversion</td>
</tr>
...
</table>
PS: Wenn Sie einige gute groovy Tutorials kennen, lassen Sie mich wissen :)