我要加载另一个FXML,当单击程序中的tablecolumn对象时,该怎么办?这是我的代码: 列是:imdb,name,genre; 感谢您的事先帮助,我将这个项目作为我的作业 我知道有关鼠标事件的一些信息,但我没有尝试单击 桌柱了,如果您能帮助我,我将不胜感激
import java.awt.event.MouseEvent;
import java.net.URL;
import java.util.Random;
import java.util.ResourceBundle;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
public class FXMLDocumentController implements Initializable {
@FXML
private TableView tableview;
@FXML
private TableColumn director;
@FXML
private TableColumn name;
@FXML
private TableColumn genre;
@FXML
private ComboBox combobox;
@FXML
private Label addresslabel;
@FXML
private Label labeladdress;
@Override
public void initialize(URL url, ResourceBundle rb) {
labeladdress.setText("Misamarti");
name.setCellValueFactory(new PropertyValueFactory("name"));
director.setCellValueFactory(new PropertyValueFactory("director"));
genre.setCellValueFactory(new PropertyValueFactory("genre"));
for (int i = 0; i < CinemaProject.cinemaArr.size(); i++) {
combobox.getItems().add(CinemaProject.cinemaArr.get(i).getName());
}
combobox.valueProperty().addListener(new ChangeListener() {
@Override
public void changed(ObservableValue observable, Object oldValue, Object newValue) {
Data.getCinemadata();
Data.getMoviesData();
tableview.getItems().clear();
for (int i = 0; i < CinemaProject.cinemaArr.size(); i++) {
if (combobox.getValue().equals(CinemaProject.cinemaArr.get(i).getName())) {
addresslabel.setText(CinemaProject.cinemaArr.get(i).getMisamarti());
tableview.getItems().addAll(CinemaProject.movieArr);
break;
}
}
}
});
}
}