问题标签 [javafx-tableview]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
checkbox - Working checkboxes in JavaFX table (CheckBoxTableCell)
(This is similar to a homework question.)
I recently made an example UI in Scenebuilder for something I later had to program with Java Swing. That more or less worked. Now it is my task, not for the actual development of the program, but for learning something in my job training, to make a similar UI with Scenebuilder, but this time an actually working one. The specifications are:
- It's a window with a table in it.
- At least two of the columns have radio boxes in them that look like checkboxes or checkboxes that act like radio boxes (because the company has weird standards).
- It uses FXML files made with Scenebuilder for the layout.
Making the check boxes act as radio boxes should be easy, if I could just enable the editing. I found a lot of examples that do almost what I want, but are still all not really applicable to my situation. Here are some of them:
- I started with this video and almost exactly copied the code to first have a working example. Then I adjusted it to my needs until I only had the check boxes to do (first working prototype had Booleans instead).
- Then I took part of the full code of this answer to add the check boxes. That worked, but they don't react to clicks.
- This, this and this seems to only apply to text fields, not checkboxes.
- I then used the two lambda expressions from the second code block in this answer (actually I used the variant in the first answer and manually resolved some errors until suddenly Eclipse automatically converted it to lambda expressions). I also added the
public ObservableValue<Boolean> getCompleted()
method, Eclipse suggested some magic and then I had what you can see in the corresponding code below (without the console print). - I also added a listener to the boolean property, like this site (archive) apparently does (I think), but that doesn't seem like it helped much.
Here is a picture of how the dialog looks now, I still can't use the check boxes:
My question: How can I make it so that the check boxes react to clicks? React can mean outputting something on the console, I don't need a given code that makes it automatically disable the other checkbox, I want to figure that part out myself.
My code:
src.controller.MainController.java
src.controller.MainView.java
src.controller.MainController.fxml
src.view.Table.java
java - 如何在表格结构的所有列中分配总宽度?”
我正在尝试编写一个自定义调整大小策略,其作用类似于TableView.CONSTRAINED_RESIZE_POLICY
它将所有可见列的总宽度设置为表中的总可用宽度,以便水平滚动条永远不会出现。
我正在使用该行double widthAvailable = table.getWidth() - getScrollbarWidth(table);
来尝试执行此操作(请参阅下面的完整代码)。
不幸的是,这个计算似乎返回4
了太多。我的猜测是,我还应该从我缺少的表格宽度中减去一些其他的东西,在默认的 JavaFX 主题中恰好是 4 像素宽。
这是一个演示问题的完整程序:
看看桌子比它应该的宽一点吗?我希望能够设置列的宽度,以便不出现水平滚动条。
java - 双击列标题的分隔符时未触发 CustomResizePolicy
我为 a 编写了一个自定义调整大小策略,TableView
类似于TableView.CONSTRAINED_RESIZE_POLICY
可见列的总宽度始终等于表格本身的宽度。
每当调整列大小时,无论是通过调整表大小还是用户拖动列,都会调用调整大小策略并适当调整列大小。
但是,当双击表格标题中的一个分隔符(以“收缩”列的内容)时,不会触发自定义调整大小策略。
结果,列的总宽度可能大于或小于表格的宽度,这是不好的。
如何检测这些双击并导致我CustomResizePolicy
之后触发呼叫?
这是一个工作示例,显示双击不会导致调用CustomResizePolicy
:
java - How to select multiple values by using ComboBoxTableCell or ChoiceBoxTableCell in Table View javafx
I have a tableview where user can double click on a column row & Combo Box drop down will appear with list of items. Here problem is user can only select one value at a time instead I want to allow user to select multiple values.
Existing Implementation using ComboBoxTableCell
[]
Existing Implementation using ChoiceBoxTableCell
java - 如何在 JAVAFX TABLEVIEW 中选择特定的表索引
我想在我的例如 tableview.index(0).getSelectedItem(); 中选择特定索引 像这样的东西。我做到了,但我只能选择最后一行。类似 selectLast(); 安静类似于我想做的事情。如何在 javafx 中做到这一点,我是这种语言的安静初学者,希望我确实指出了我想说的。