我正在使用TableModel
具有伴随 custom 的自定义ColumnModel
。下面是它所在面板的代码。
该表工作得很好,我可以毫无困难地添加和删除列,但标题永远不会显示。我将如何解决这个问题?
val panel = new BorderPanel() {
var sourceLabel = new Label("No file chosen")
layout(sourceLabel) = North
var tableModel = new LogRecordTableModel
var dataTable = new Table {
model = tableModel
peer.setColumnModel(tableModel.columnModel)
}
val scrollPane = new ScrollPane(dataTable)
layout(scrollPane) = Center
layout(controlStrip) = South
openAction.setParent(this)
listenTo(openAction)
reactions += {
case f:FileChosen =>
tableModel.setSource(f.file)
updateFile(f.file)
}
listenTo(previousAction)
reactions += {
case PREVIOUS =>
tableModel.previous()
updateButtons()
}
listenTo(nextAction)
reactions += {
case NEXT =>
tableModel.next()
updateButtons()
}
def updateFile(file: File) {
sourceLabel = new Label(file.getName)
layout(sourceLabel) = North
Thread.sleep(100)
updateButtons()
revalidate()
main.repaint()
}
def updateButtons() {
nextButton.enabled = tableModel.hasNext
previousButton.enabled = tableModel.hasPrevious
}
def updateTypeControl() {
println("[$lessanonymous$greater.updateTypeControl] enter.")
typeControl.selection.item(tableModel, typeValues.selection.item)
}
}