我正在构建 JavaFX 待办事项列表,但不确定如何继续。右键单击弹出菜单工作正常,但我不知道如何编辑/更改ListView其他内容,而不仅仅是删除它们。LocalEvent e = a string somehow?我正在尝试在 Javafx 的右键单击弹出菜单中做 4 件事:完成是在项目旁边放置一个复选标记并删除该项目。Nest 是从列表项创建嵌套列表(完全不知道如何)。编辑是使列表项可编辑并保存更改。删除作品:)我通过将以下内容添加到 fxml 文件来完成此操作:<JFXListView fx:id="eventList" editable="true" layoutX="24.0" layoutY="106.0" prefHeight="354.0" prefWidth="939.0"><contextMenu> <ContextMenu> <items> <MenuItem fx:id="popUp" mnemonicParsing="false" onAction="#Done" text="Done" /> <MenuItem fx:id="popUp3" mnemonicParsing="false" onAction="#Remove" text="Remove" /> <MenuItem fx:id="popUp1" mnemonicParsing="false" onAction="#Nest" text="Nest" /> <MenuItem fx:id="popUp2" mnemonicParsing="false" onAction="#Edit" text="Edit" /> </items> </ContextMenu> </contextMenu></JFXListView>`这是我的 Controller.java 文件:package application;import java.net.URL;import java.time.LocalDate;import java.util.ResourceBundle;import com.jfoenix.controls.JFXButton;import com.jfoenix.controls.JFXListView;import com.jfoenix.controls.JFXTextField;import javafx.collections.FXCollections;import javafx.collections.ObservableList;import javafx.event.ActionEvent;import javafx.fxml.FXML;import javafx.fxml.Initializable;import javafx.scene.control.DatePicker;import javafx.scene.control.MenuItem;import javafx.scene.input.MouseEvent;public class Controller implements Initializable{ @Override public void initialize(URL url, ResourceBundle rb) { datePicker.setValue(LocalDate.now()); eventList.setExpanded(true); eventList.depthProperty().set(1); } @FXML private MenuItem popUp; @FXML private JFXTextField textBox; @FXML private JFXListView<LocalEvent> eventList; ObservableList<LocalEvent> list = FXCollections.observableArrayList(); @FXML private JFXButton AddButton; @FXML private DatePicker datePicker;
添加回答
举报
0/150
提交
取消