【问题标题】:how to implement multi imageView select holding control button in javaFX如何在javaFX中实现多imageView选择按住控制按钮
【发布时间】:2016-08-08 20:11:42
【问题描述】:

在我的 JAVAFX 应用程序中,我在 tilepane 中有图像视图,我想实现类似于 android 中图像的多选功能。我尝试在单击事件时向 imageView 添加边框样式,但这没有用。有什么办法可以做到这一点。

【问题讨论】:

    标签: java imageview javafx-2 multi-select javafx-css


    【解决方案1】:

    您可以将Image 嵌入到JavaFX Button 中,并设置ButtonOnAction 方法:

    imageButton.setOnAction(new EventHandler<ActionEvent>() {
        @Override public void handle(ActionEvent e) {
            System.out.println("Changing the color of the button's border :");
            imageButton.setStyle("-fx-border-color:blue;");
            System.out.println("For further reference, you can save the button or the image in a TreeSet:");
            treeSet.add(imageButton);
        }
    }); 
    

    如果一个简单的点击就足以选择图像,你可以像上面那样定义Button的OnAction方法。但是,如果您需要长按(Android 样式中的长按)来更改图像的选择状态,您可以在此处找到有关“长按”的更多信息:how to achieve javafx mouse event "push and hold"?

    【讨论】:

    • 很高兴,不要犹豫,验证答案!
    猜你喜欢
    • 2018-10-15
    • 1970-01-01
    • 2012-09-17
    • 1970-01-01
    • 2011-11-04
    • 1970-01-01
    • 2017-06-11
    • 2023-04-02
    • 2012-05-22
    相关资源
    最近更新 更多