Tag: javafx

CellCache在TableView中用tornadoFX意外渲染

我只是困惑于与Kotlin的cellCache函数的使用。 渲染总是奇怪而且意想不到,那会发生什么? 代码在这里: data class Person(var name : String, var age : Int, var sex : Boolean) class MyView: View() { val list = listOf( Person(“Name A”, 20, false), Person(“Name B”, 22, false), Person(“Name C”, 21, true), Person(“Name D”, 30, true), Person(“Name E”, 35, true) ).observable() override val root = stackpane { vbox { tableview(items […]

JavaFX的。 如何使用FXML编辑TableViewCell?

我想只使用fxml使TableViewCell。 我该怎么做。 现在我有一个模型类DuplicateFileInfo class DuplicateFileInfo(var id: Long, var path: String, var editableField: String?) {} 我有TableView 在这种情况下,我有可编辑的表格视图。 但编辑完成后该值不会设置为模型。 是否有可能使这项工作没有codding?

JFoenix:JFXPopup周围不需要的填充

我创建了一个JavaFX应用程序,使用JFoenix库进行样式设计,使其具有Material Design的外观和感觉。 在右上角有一个类似Android的菜单。 打开时显示一个JFXPopup。 但是,有不希望的填充? 在它周围,我无法删除(按钮上方的白色空间更精确)。 看到下面的图片: 在内部,有一个包含JFXHamburger的JFXRippler。 菜单项以及菜单/popup窗口的打开是通过以下(Kotlin)代码以编程方式完成的: // Create list items val list = JFXListView() for (i in 1..4) list.items.add(“Item ” + i) // Create the popup and open it when the menu item is clicked val popup = JFXPopup(list) ripplerMenu.setOnMouseClicked { popup.show(ripplerMenu, PopupVPosition.TOP, PopupHPosition.RIGHT) } 我已经尝试了以下的东西: 使用ripplerMenu.background = Background.EMPTY设置JFXRippler组件的ripplerMenu.background = Background.EMPTY 通过CSS我试图设置jfx-popup-container和jfx-list-view类的背景 […]

如何在GSON中反序列化Kotlin代表

我有这个class级: class Project { val nameProperty = SimpleStringProperty(“foobar”) val name by nameProperty } 我使用Fx-GSON库来序列化JavaFx属性。 当我序列化到JSON我得到这个: { “nameProperty”: “foobar”, “name$delegate”: “foobar” } 但是,当我将其反序列化回到Projecttypes的对象时, name和nameProperty是2个不同的对象 。 如何使name属性委托给新的nameProperty ?

在gradle应用程序中找不到ant-javafx

在使用JavaFX编写我的第一个应用程序时,我确保JAVA_HOME安装正确,并将javafx-gradle-plugin到我的应用程序中,但是在我的JDK中有一个缺少实际可用的ant-javafx-library的错误: 我的build.gradle和我得到的错误信息如下: // set up the kotlin-gradle plugin buildscript { ext.kotlin_version = ‘1.1.60’ repositories { mavenLocal() // mavenCentral() } dependencies { classpath “org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version” classpath “de.dynamicfiles.projects.gradle.plugins:javafx-gradle-plugin:8.8.2” } } // apply the kotlin-gradle plugin apply plugin: “kotlin” apply plugin: ‘javafx-gradle-plugin’ // add kotlin-stdlib dependencies. repositories { mavenLocal() // mavenCentral() } dependencies { //dependencies from a remote repositor […]

JavaFX重置图形上下文

我正在使用Kotlin和TornadoFX / JavaFX重绘每1/60秒的video游戏。 目前,我的程序通过将背景设置为白色并绘制而重绘。 不过,我宁愿一些更清洁的东西。 这是我目前正在绘制它的方式: private fun drawShapes(gc: GraphicsContext) { gc.fill = c(255, 255, 255) gc.fillRect(0.0, 0.0, 700.0, 700.0) //Game is 700×700 gc.fill = c(94, 132, 233) walls.forEach { gc.fillRect(it.x.toDouble(), it.y.toDouble(), it.w.toDouble(), it.h.toDouble()) } gc.fill = c(255, 239, 20) coins.filter { !it.collected }.forEach { gc.fillRect(it.x.toDouble(), it.y.toDouble(), it.w.toDouble(), it.h.toDouble()) } //Cut off here because following […]

无法让TextArea滚动到底部

我正在使用JavaFX的Kotlin。 在以编程方式添加的TextArea中,我希望滚动条总是在添加文本时跳到底部。 为了测试这个,我写了这个代码: taConsole.text = “Running ” + pythonScriptPath // retrieve output from python script val bfr = BufferedReader(InputStreamReader(p.inputStream)) val lines = bfr.readLines() for (i in 1..10) { for (line in lines) { taConsole.appendText(“\n” + line) } } 可悲的是,我不能让它滚动到底部。 我已经尝试过了: ta.selectEnd(); ta.deselect(); dataPane.setScrollTop(Double.MAX_VALUE); 和 val caret = taConsole.selectPositionCaret(taConsole.length) 我插入他们后: appendText(“\n” + line)

你如何在Kotlin中实现JavaFX ZoomEvent?

我参与了一个名为“Path Visualizer”的应用程序,它与JavaFXcanvas一起工作。 我对JavaFX很新,并且已经遍布互联网寻找解决这个问题的答案。 我的短期目标是允许跟踪板的缩放function。 这是我的代码片段,不包括主要的方法(注意:你可以在我实现缩放方法之前忽略代码,我只是想包括它,因为它可能是有帮助的): override fun start(stage: Stage) { stage.title = “Path Visualizer” // set up the paths and autos selectedAutonomous = Autonomous(“Auto1”) mapAutonomous.put(selectedAutonomous!!.name, selectedAutonomous!!) selectedPath = DefaultPath selectedAutonomous!!.putPath(selectedPath!!.name, selectedPath!!) // setup the layout val buttonsBox = VBox() buttonsBox.spacing = 10.0 addControlsToButtonsBox(buttonsBox) val stackPane = StackPane(canvas) val splitPane = SplitPane(stackPane, buttonsBox) splitPane.setDividerPositions(0.7) stage.scene = […]

如何在kotlin的JavaFX图表中添加一个系列

说我有一个系列: val series: XYChart.Series = XYChart.Series() series.data.addAll(myData.map { pair -> XYChart.Data(pair.key, pair.value) }) 现在我想创建一个折线图如下: val xAxis = NumberAxis() val yAxis = NumberAxis() val lineChart = LineChart(xAxis, yAxis) lineChart.data.add(series) 但是,当我这样做,我得到以下错误: Error:(xx, xx) Kotlin: Type mismatch: inferred type is XYChart.Series but XYChart.Series! was expected 有没有办法解决这个问题,而不改变myMap的键和值types为Number (哪些工作)? 对于我来说, Int和Long都是从Numberinheritance的,所以在这里应该没有任何问题。 理想情况下,我希望能够映射一个数据集(在本例中为myData ),而不必实际修改数据集本身或者使用正确的types(看起来很昂贵)制作数据集的副本。 有人可能也可以解释为什么linChart.data.add(series)期望XYChart.Series! ,或者更具体地说,为什么我会得到一个错误,如果它期望这个? 因为我感到我传递的是无关紧要的印象! 意味着你可以通过任何事情; 要么是一个可能为null的序列,要么是一个显式不为null的序列。

平滑地改变一个JavaFX效果

是否有可能在JavaFX中顺利地改变效果? 我已经尝试了很多选择,但没有任何工作。 例如 – Java: void effectChange(Node node) { // Node Effect = ColorAdjust (0.0, 0.0, 0.0, 0.0) KeyValue keyValue = new KeyValue(node.effectProperty(), new ColorAdjust(-0.8, 0.0, 0.0, 0.0)); KeyFrame keyFrame = new KeyFrame(Duration.seconds(2.0), keyValue); Timeline timeline = new Timeline(keyFrame); timeline.play(); } 例如 – Kotlin: fun effectChange(node: Node) { // Node Effect = ColorAdjust (0.0, 0.0, […]