Hello
Thanks for the advice. The SpreadsheetView from ControlsFX looks really promissing, so that I gave it a try. I am working on it for more than a day now, but no luck so far. Here is what I've got:
package TestSpreadSheetView
/* Content of build.sbt:
name := "TestSpreadSheetView"
scalaVersion := "2.13.3"
libraryDependencies += "org.scalafx" %% "scalafx" % "15.0.1-R21"
libraryDependencies += "org.controlsfx" % "controlsfx" % "8.40.18"
javacOptions ++= Seq("-source", "1.8", "-target", "1.8")
scalacOptions += "-target:jvm-1.8"
*/
import org.controlsfx.control.spreadsheet.{GridBase, SpreadsheetCell, SpreadsheetCellType, SpreadsheetView}
import scalafx.Includes._
import scalafx.application.JFXApp
import scalafx.collections.ObservableBuffer
import scalafx.scene.Scene
import scalafx.scene.layout.StackPane
import scalafx.stage.Stage
object Main extends JFXApp {
val rowCount: Int = 15 //Will be re-calculated after if incorrect.
val columnCount: Int = 10
val grid = new GridBase(rowCount, columnCount)
val spreadSheetView = new SpreadsheetView(grid)
spreadSheetView.setEditable(true)
spreadSheetView.setShowRowHeader(true)
spreadSheetView.setShowColumnHeader(true)
val rows: ObservableBuffer[ObservableBuffer[SpreadsheetCell]] = new ObservableBuffer[ObservableBuffer[SpreadsheetCell]]() //FXCollections.observableArrayList < ObservableList < SpreadsheetCell >> ()
val list = new ObservableBuffer[SpreadsheetCell]() //FXCollections.observableArrayList < SpreadsheetCell > ()
list += SpreadsheetCellType.STRING.createCell(0, 0, 1, 1, "row0-col0")
list += SpreadsheetCellType.STRING.createCell(0, 1, 2, 1, "row0-col1")
list += SpreadsheetCellType.STRING.createCell(0, 2, 1, 1, "row0-col2")
rows += list
list.clear()
list += SpreadsheetCellType.STRING.createCell(1, 0, 1, 1, "row1-col0")
//commenting row1-col1 as row0-col1 has a rowspan of 2
//list += SpreadsheetCellType.STRING.createCell(1, 1, 1, 1, "row1-col1")
list += SpreadsheetCellType.STRING.createCell(1, 2, 1, 1, "row1-col2")
rows += list
list.clear()
list += SpreadsheetCellType.STRING.createCell(2, 0, 1, 1, "row2-col0")
list += SpreadsheetCellType.STRING.createCell(2, 1, 1, 1, "row2-col1")
list += SpreadsheetCellType.STRING.createCell(2, 2, 1, 1, "row2-col2")
rows += list
list.clear()
list += SpreadsheetCellType.STRING.createCell(3, 0, 1, 1, "row3-col0")
list += SpreadsheetCellType.STRING.createCell(3, 1, 1, 1, "row3-col1")
list += SpreadsheetCellType.STRING.createCell(3, 2, 1, 1, "row3-col2")
rows += list
/* Next line will not compile*/
grid.setRows(rows) //rows has the wrong type!!!
val centerPane: StackPane = new StackPane() {
children += spreadSheetView
}
val parentStage: Stage = new JFXApp.PrimaryStage {
title = "Test for SpreadSheetView"
resizable = true
width = 1000
height = 800
scene = new Scene {
root = centerPane
}
}
}
The problem is in the grid for the control. It won't accept an ObservableBuffer and I can't figure out how to import an FXCollections.observableArrayList.
I also checked out the chapter on Unwrapped components on
scalafx.org.
By the way, the example with a dialog from controlsFX there doesn't work anymore. It seems that Dialog has been deprecated and/or moved to another library.
I'd be willing to translate the example:
to Scala to put it there.
But for someone with the required skills it is probably easier just to do it than teach it to me (I only know scala, not java).
As I said, any help would be appreciated.