表使用groovy的swing构建器
到目前为止,我已经开发了PHP和JavaScript。我目前正在学习groovy,但不幸的是关于这种语言和书的教程并不多,我正在阅读(Groovy Recipes),并没有包含任何关于使用groovy的swingbuilder的内容。
作为一个工作项目,我想创建一个类似于下面的模式的表:
Instancename
groupId artifactId DEV TEST PROD
firstgroup firstartifact 1.00 1.05 1.05
secondgroup secondartifact 2.02 2.00 2.00
这是我目前的代码:
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();
}
}
当我运行它时,我得到的表填充了我的数据。我的问题是,如何将“DEV”,“TEST”和“PROD”从属于“Instancename”?我不知道如何在其他人之上添加标题。
在HTML中它看起来像这样:
<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:如果你知道一些很好的groovy教程,请告诉我:)
没有找到相关结果
已邀请:
1 个回复
嘘崇蔡对