Javafx表行边框导致元素在

问题描述:

上移动我试图给选定的表格行添加一个红色边框,并且该行中的元素正在移动。Javafx表行边框导致元素在

这是我的CSS:

.my-table .table-row-cell:filled:selected { 
    -fx-border-color: red; 
} 

这是怎么看起来像一个屏幕截图。

enter image description here

我如何纠正呢? 我试过改变边界插图,但它似乎没有效果。

-fx-background-insets: 0, 1 ; 

创建表的代码是:

<TableView styleClass="my-table" editable="false" > 
    <columns> 
     <TableColumn fx:id="columnNumber" minWidth="70" prefWidth="70" sortable="false" text="Solution" /> 
     <TableColumn fx:id="columnOne" minWidth="0" prefWidth="40" sortable="false" text="columnOne" /> 
     <TableColumn fx:id="columnTwo" minWidth="40" prefWidth="40" sortable="false" text="columnTwo" /> 
     <TableColumn fx:id="columnThree" minWidth="70" prefWidth="70" sortable="false" text="columnThree" /> 
     <TableColumn fx:id="columnFour" minWidth="40" prefWidth="40" sortable="false" text="columnFour" /> 
     <TableColumn fx:id="columnFive" minWidth="80" prefWidth="80" sortable="false" text="columnFive" /> 
     <TableColumn fx:id="columnSix" minWidth="80" prefWidth="80" sortable="false" text="columnSix" /> 
     <TableColumn fx:id="columnSeven" minWidth="80" prefWidth="80" sortable="false" text="columnSeven" /> 
     <TableColumn fx:id="columnEight" minWidth="180" prefWidth="180" sortable="false" text="columnEight" /> 
     <TableColumn fx:id="action" minWidth="100" prefWidth="100" sortable="false" text="" /> 
    </columns> 
</TableView> 

应用的样式:

.table-view { 
    -fx-table-cell-border-color: transparent; 
} 
+1

你能否也请提供创建表的代码?还请提供填充表格的代码。 – nfs

她的是一个肮脏的修复:

.my-table .table-row-cell:filled:selected { 
    -fx-border-color: red; 
    -fx-border-insets: 0 -1 0 -1; 
} 

或者

.my-table .table-row-cell:filled:selected { 
    -fx-border-color: red; 
    -fx-padding: -1; 
}