2

我一直在尝试从表格视图中删除空行,但我无法使用我在一些博客中阅读的 css 来做到这一点

这是我正在应用的css /---------------------------------------- ----------

.table-row-cell:empty {
    -fx-background-color: white;
}

.table-row-cell:empty .table-cell {
    -fx-border-width: 0px;
}

/----------------------------------------------------

但我得到了错误

/------------------------------------

SEVERE: javafx.scene.control.Control loadSkinClass Failed to load skin 'com.sun.javafx.scene.control.skin.TableRowSkin' for control TableView@125ff34[styleClass=table-view table-row-cell]
java.lang.IllegalArgumentException: argument type mismatch
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
    at javafx.scene.control.Control.loadSkinClass(Unknown Source)
    at javafx.scene.control.Control.impl_cssSet(Unknown Source)
    at javafx.scene.Node.impl_cssSet(Unknown Source)
    at com.sun.javafx.css.StyleHelper.transitionToState(Unknown Source)
    at javafx.scene.Node.impl_processCSS(Unknown Source)
    at javafx.scene.Parent.impl_processCSS(Unknown Source)
    at javafx.scene.control.Control.impl_processCSS(Unknown Source)
    at javafx.scene.Parent.impl_processCSS(Unknown Source)
    at javafx.scene.Parent.impl_processCSS(Unknown Source)
    at javafx.scene.Node.processCSS(Unknown Source)
    at javafx.scene.Node.processCSS(Unknown Source)
    at javafx.scene.Scene.doCSSPass(Unknown Source)
    at javafx.scene.Scene.access$2900(Unknown Source)
    at javafx.scene.Scene$ScenePulseListener.pulse(Unknown Source)
    at com.sun.javafx.tk.Toolkit.firePulse(Unknown Source)
    at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(Unknown Source)
    at com.sun.javafx.tk.quantum.QuantumToolkit$8.run(Unknown Source)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.access$100(Unknown Source)
    at com.sun.glass.ui.win.WinApplication$2$1.run(Unknown Source)
    at java.lang.Thread.run(Thread.java:722)

SEVERE: javafx.scene.control.Control impl_processCSS The -fx-skin property has not been defined in CSS for TableView@125ff34[styleClass=table-view table-row-cell]

/---------------------------------------------------- ------------

有人知道如何解决吗?或任何其他方式来删除空行。

提前致谢。

4

2 回答 2

1

您的 css 适用于 JavaFX 2.1。接下来试试:

  • 更新到 JavaFX 2.1
  • 从您的 css 文件中删除除这些类之外的所有内容

在此处输入图像描述

于 2012-04-26T16:00:03.393 回答
0

这是解决方案:在您的 css 文件中添加以下内容:

.table-row-cell:empty:odd, .table-row-cell:empty:even {
    -fx-background-color: transparent;
}

测试并为我工作

点击显示我的表格视图

于 2018-03-23T21:41:40.367 回答