当前位置: 首页>>代码示例>>Java>>正文


Java TreeView.setOnMouseClicked方法代码示例

本文整理汇总了Java中javafx.scene.control.TreeView.setOnMouseClicked方法的典型用法代码示例。如果您正苦于以下问题:Java TreeView.setOnMouseClicked方法的具体用法?Java TreeView.setOnMouseClicked怎么用?Java TreeView.setOnMouseClicked使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javafx.scene.control.TreeView的用法示例。


在下文中一共展示了TreeView.setOnMouseClicked方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initGUI

import javafx.scene.control.TreeView; //导入方法依赖的package包/类
private void initGUI() {
    //Search facility
    Label searchLabel = new Label();
    Image dirImage = new Image("icon/ZOOM_IN.png");
    searchLabel.setGraphic(new ImageView(dirImage));
    keywordInput = new TextField("Type in search keyword...");
    keywordInput.setPrefWidth(230);
    //Add actionlistener
    keywordInput.textProperty().addListener((observalbe, oldvalue, newvalue)->{           
       updateTreeView(newvalue.toUpperCase());
    });
    //Add focus listener
    keywordInput.focusedProperty().addListener((observalbe, oldvalue, newvalue)->{
        if (newvalue) {
           if (getNodeLayerCount(currentSelectedNode) >= 2) {
              keywordInput.setText("");
           }
        }
    });
    HBox hBox = new HBox();
    hBox.setSpacing(5);
    hBox.getChildren().addAll(searchLabel, keywordInput);
    setTop(hBox); 
    treeView = new TreeView();
    treeView.setMinWidth(200);;
    treeView.setEditable(false);
    treeView.setOnMouseClicked(onTreeItemClicked()); //<-Handle mouse click event
    setCenter(treeView);
}
 
开发者ID:ztan5,项目名称:TechnicalAnalysisTool,代码行数:30,代码来源:MarketDataTreeViewNode.java

示例2: CannedTextTreeStage

import javafx.scene.control.TreeView; //导入方法依赖的package包/类
public CannedTextTreeStage(boolean hidden){


        TreeBranch<CannedTextItem> treeRoot = CannedText.getDefaultTree();
        final CannedTextItemTreeFinder finder = new CannedTextItemTreeFinder(treeRoot);

        // http://docs.oracle.com/javafx/2/api/javafx/scene/control/TreeItem.html
        // store label in label
        // store id in setValue
        TreeItem<TreeKeyValue> displayTreeRoot = new TreeItem<>(new TreeKeyValue("",treeRoot.getLabel()));

        addTreeChildrenToDisplayTree(treeRoot, displayTreeRoot);

        BorderPane root = new BorderPane();

        final TreeView<TreeKeyValue> displayTreeView = new TreeView<>(displayTreeRoot);

        root.setCenter(displayTreeView);

        Scene scene = new Scene(root, Config.getDefaultWindowWidth(), Config.getDefaultWindowHeight());
        this.setTitle("Canned Text Tree");
        this.setScene(scene);
        if(!hidden)
            this.show();


        displayTreeView.setOnMouseClicked(
                new EventHandler<MouseEvent>() {
                    @Override
                    public void handle(MouseEvent event) {
                        if(event.getClickCount()==2){
                            TreeItem<TreeKeyValue> item = displayTreeView.getSelectionModel().getSelectedItem();
                            // add the value to the clipboard
                            if(item.getValue().key!=""){
                                // find it in the CannedTextTree
                                CannedTextItem texty = finder.find(item.getValue().key);
                                // get the value
                                if(texty!=null)
                                    sendToClipboard(texty.getTextValue());
                            }
                        }
                    }
                }
        );

    }
 
开发者ID:eviltester,项目名称:testtoolhub,代码行数:47,代码来源:CannedTextTreeStage.java


注:本文中的javafx.scene.control.TreeView.setOnMouseClicked方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。