如何在TabPane中的Tab Down按钮上有一个onMouseClicked监听器?
答案 0 :(得分:3)
我们可以向TabPane添加一个MouseEvent处理程序,如果在那里点击则找到箭头:
tabPane.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent> () {
@Override
public void handle(MouseEvent mouseEvent) {
EventTarget eventTarget = mouseEvent.getTarget();
if (eventTarget instanceof StackPane) {
StackPane stackPane = (StackPane) eventTarget;
ObservableList<String> styleClasses = stackPane.getStyleClass();
for (String styleClass : styleClasses) {
if ("arrow".equals(styleClass) == true) {
//TODO
System.out.println("arrowEvent");
}
}
}
}
});