當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。