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


Java JTree.setEditable方法代码示例

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


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

示例1: ViewTreeGroups

import javax.swing.JTree; //导入方法依赖的package包/类
public ViewTreeGroups(String directory) {
	//super("JTree FileSystem Viewer - JavaProgrammingForums.com");
	setTitle("GroupsTree Structure");
	fileDetailsTextArea.setEditable(false);
	fileSystemModel = new FileSystemModel(new File(directory));
	fileTree = new JTree(fileSystemModel);
	fileTree.setEditable(true);
	fileTree.addTreeSelectionListener(new TreeSelectionListener() {
		public void valueChanged(TreeSelectionEvent event) {
			File file = (File) fileTree.getLastSelectedPathComponent();
			fileDetailsTextArea.setText(getFileDetails(file));
		}
	});
	JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
			true, new JScrollPane(fileTree), new JScrollPane(
					fileDetailsTextArea));
	getContentPane().add(splitPane);
	setDefaultCloseOperation(EXIT_ON_CLOSE);
	setSize(640, 480);
	setVisible(true);
}
 
开发者ID:cyberheartmi9,项目名称:Mona-Secure-Multi-Owner-Data-Sharing-for-Dynamic-Group-in-the-Cloud,代码行数:22,代码来源:ViewTreeGroups.java

示例2: TreePanel

import javax.swing.JTree; //导入方法依赖的package包/类
public TreePanel(GraphPanel<?, ?> graphpanel) {
	super(new BorderLayout());

	tree = new JTree(createTreeModel());
	tree.setEditable(false);

	add(new JScrollPane(tree), BorderLayout.CENTER);

	// Prevents interception of F2 Keystroke.
	// getInputMap().getParent() seems never to be null
	tree.getInputMap().getParent().remove(
			KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0));

	graphPanelListener = new PropertyChangeListener() {
		@Override
		public void propertyChange(PropertyChangeEvent evt) {
			if (evt.getPropertyName().equals("Viewers")) {
				if (evt.getOldValue() instanceof LayerViewer<?, ?>
						&& evt.getNewValue() == null)
					onLayerViewerRemove((LayerViewer<?, ?>) evt
							.getOldValue());
				else if (evt.getNewValue() instanceof LayerViewer<?, ?>
						&& evt.getOldValue() == null)
					onLayerViewerAdd((LayerViewer<?, ?>) evt.getNewValue());
			} else if (evt.getPropertyName().equals("LayerStack")) {
				onLayerStackChange((AbstractLayerStack<?>) evt
						.getOldValue(), (AbstractLayerStack<?>) evt
						.getNewValue());
			}
		}
	};
	setGraphPanel(graphpanel);
}
 
开发者ID:KeepTheBeats,项目名称:alevin-svn2,代码行数:34,代码来源:TreePanel.java

示例3: DynamicTree

import javax.swing.JTree; //导入方法依赖的package包/类
public DynamicTree() {
    super(new GridLayout(1, 0));

    rootNode = new DefaultMutableTreeNode("Root Node");
    treeModel = new DefaultTreeModel(rootNode);
    treeModel.addTreeModelListener(new MyTreeModelListener());
    tree = new JTree(treeModel);
    tree.setEditable(true);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    tree.setShowsRootHandles(true);

    JScrollPane scrollPane = new JScrollPane(tree);
    add(scrollPane);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:15,代码来源:DynamicTree.java

示例4: init

import javax.swing.JTree; //导入方法依赖的package包/类
private void init() {
    treeModel.setRoot(createRoot());

    tree = new JTree(treeModel) {
        @Override
        public TreeCellRenderer getCellRenderer() {
            TreeCellRenderer renderer = super.getCellRenderer();
            if (renderer == null)
                return null;
            ((DefaultTreeCellRenderer) renderer).setLeafIcon(new ImageIcon(
                    getClass().getResource("/images/function.png")));
            return renderer;
        }
    };

    tree.setCellRenderer(new Renderer());

    tree.setEditable(true);

    tree.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if ((e.getButton() == MouseEvent.BUTTON1)
                    && (e.getClickCount() == 2)) {
                openDiagram();
            }
        }

    });

    tree.setRootVisible(true);

    JScrollPane pane = new JScrollPane();
    pane.setViewportView(tree);
    this.add(pane, BorderLayout.CENTER);
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:37,代码来源:ModelsPanel.java

示例5: addWindowTab

import javax.swing.JTree; //导入方法依赖的package包/类
private void addWindowTab() {
    if (compNode instanceof WindowNode
            && ((WindowNode) compNode).getWindows().length > 0) {
        winTree = new JTree(((WindowNode) compNode).getWindowModel());
        winTree.setCellRenderer(renderer);
        winTree.setEditable(false);
        winTree.addTreeSelectionListener(selManager);
        winSplit = createUnderPane(winTree);
        tbd.add(WINDOWS_TAB, winSplit);
    }

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:GUIBrowser.java

示例6: addComponentTab

import javax.swing.JTree; //导入方法依赖的package包/类
private void addComponentTab() {
    if (compNode instanceof ContainerNode
            && ((ContainerNode) compNode).getComponents().length > 0) {
        componentTree = new JTree(((ContainerNode) compNode).getComponentModel());
        componentTree.setCellRenderer(renderer);
        componentTree.setEditable(false);
        componentTree.addTreeSelectionListener(selManager);
        componentSplit = createUnderPane(componentTree);
        tbd.add(COMPONENTS_TAB, componentSplit);
    }

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:GUIBrowser.java

示例7: addReflectionTab

import javax.swing.JTree; //导入方法依赖的package包/类
private void addReflectionTab() {
    methodTree = new JTree(compNode.getMethodsModel());
    methodTree.setCellRenderer(renderer);
    methodTree.setEditable(false);
    methodTree.addTreeSelectionListener(selManager);
    tbd.add(REFLECTION_TAB, new JScrollPane(methodTree));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:GUIBrowser.java

示例8: setupInstance

import javax.swing.JTree; //导入方法依赖的package包/类
protected void setupInstance(JTree instance) {
    super.setupInstance(instance);
    
    instance.setEditable(editable);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:6,代码来源:DataViewBuilders.java

示例9: setupGUI

import javax.swing.JTree; //导入方法依赖的package包/类
private void setupGUI()
{
	JButton addButton = new JButton(addAction);
	JButton removeButton = new JButton(removeAction);
	JButton addGrouping = new JButton(addGroupingAction);

	finder = new TabbedFinder(userService, filters);
	finder.setSingleSelectionOnly(false);
	finder.addFinderListener(this);

	model = new ExpressionBuilderModel();

	tree = new JTree(model)
	{
		private static final long serialVersionUID = 1L;

		@Override
		public boolean isPathEditable(TreePath path)
		{
			return ((ExpressionTreeNode) path.getLastPathComponent()).isGrouping();
		}
	};
	tree.setEditable(true);
	tree.addTreeSelectionListener(this);
	tree.setExpandsSelectedPaths(true);
	tree.setShowsRootHandles(true);
	tree.getSelectionModel().setSelectionMode(TreeSelectionModel.CONTIGUOUS_TREE_SELECTION);

	ExpressionTreeCellRenderer cellRenderer = new ExpressionTreeCellRenderer(userService);

	JComboBox<Grouping> editorCombo = new JComboBox<Grouping>();
	editorCombo.addItem(Grouping.MATCH_ANY);
	editorCombo.addItem(Grouping.MATCH_ALL);
	editorCombo.addItem(Grouping.MATCH_NONE);

	DefaultTreeCellEditor cellEditor = new DefaultTreeCellEditor(tree, cellRenderer, new DefaultCellEditor(
		editorCombo));

	tree.setCellRenderer(cellRenderer);
	tree.setCellEditor(cellEditor);

	JScrollPane treeScroller = new JScrollPane(tree);

	setLayout(new MigLayout("fill", // layout constraints
		"[grow 2, fill][][250]", // cols
		"[grow][]10[][grow][]")); // rows

	add(finder, "spany 5");
	add(treeScroller, "skip 1, spany 4, wmin 250px, grow, wrap");
	add(addButton, "wrap, wmax 45px");
	add(removeButton, "wrap, wmax 45px");
	add(addGrouping, "newline, skip 2, center");

	if( CurrentLocale.isRightToLeft() )
	{
		applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
		addButton.setText("<");
		removeButton.setText(">");
	}

	updateButtons();
}
 
开发者ID:equella,项目名称:Equella,代码行数:63,代码来源:ExpressionBuilderFinder.java

示例10: createTreePane

import javax.swing.JTree; //导入方法依赖的package包/类
public JScrollPane createTreePane() { 
	// new tree
	root = new DefaultMutableTreeNode("Root");
	tree = new JTree(root);
	tree.setEditable(false);

	// click tree
	tree.addMouseListener(new MouseAdapter() {
		public void mousePressed(MouseEvent e) {
			TreePath selPath = tree.getPathForLocation(e.getX(), e.getY());
			if (selPath != null) {
				DefaultMutableTreeNode node = (DefaultMutableTreeNode) selPath.getLastPathComponent();
				if (node.isLeaf()) {

					String type = (String) node.getUserObject();
					String strpar = node.getParent().toString();
					String strcur = node.toString(); 
					 
					String selectedObjectParent = strpar;
					selectedObject = strpar +"." + strcur;
					
					if (console.wMode == HMLP_Console.windowMode.SELECT_DB){  
						console.insertTextOut("The database \"" + selectedObject +"\" was selected.");
					} else if (console.wMode == HMLP_Console.windowMode.EDIT_DB){ 
					} else if (console.wMode == HMLP_Console.windowMode.ADD_PARENTS){ 
						console.insertTextOut("The node \"" + selectedObject +"\" was selected.");
					} else if (console.wMode == windowMode.JOIN_RELATIONS) {
						
					} else if (console.wMode == HMLP_Console.windowMode.ADD_CLD){ 
						console.insertTextOut("The node \"" + selectedObject +"\" was selected.");
					} else if (console.wMode == windowMode.LEARNING) { 
					} else if (console.wMode == windowMode.EVALUATION) { 
					} 
				}
			}
		}
	});

	// Expand all
	for (int i = 0; i < tree.getRowCount(); i++)
		tree.expandRow(i);

	return new JScrollPane(tree);
}
 
开发者ID:HML-UnBBayes,项目名称:hml,代码行数:45,代码来源:TreePanel_Left.java

示例11: createTreePane

import javax.swing.JTree; //导入方法依赖的package包/类
public JScrollPane createTreePane() { 
		// new tree
		root = new DefaultMutableTreeNode("Root");
		tree = new JTree(root);
		tree.setEditable(false);
				
		// click tree
		tree.addMouseListener(new MouseAdapter() {
			public void mousePressed(MouseEvent e) {
				TreePath selPath = tree.getPathForLocation(e.getX(), e.getY());

				if (selPath != null) {
					DefaultMutableTreeNode node = (DefaultMutableTreeNode) selPath.getLastPathComponent();
					if (node.isLeaf()) {

						TreePath[] threePaths = tree.getSelectionPaths();
						
						selectedObjects.clear();
						
						for (TreePath tp: threePaths){
							DefaultMutableTreeNode eachNode = (DefaultMutableTreeNode) tp.getLastPathComponent();
							String strpar = eachNode.getParent().toString();
							String str = strpar + "." + eachNode.toString();
							selectedObjects.add(str);
						}
						
//						String type = (String) node.getUserObject();
//						String str2 = node.toString();
//						String strpar = node.getParent().toString();
						
//						selectedObject = str2;
						
						if (console.wMode == HMLP_Console.windowMode.SELECT_DB){  
							console.insertTextOut("The database \"" + selectedObjects +"\" was selected.");
						} else if (console.wMode == HMLP_Console.windowMode.EDIT_DB){ 
						} else if (console.wMode == HMLP_Console.windowMode.ADD_PARENTS){ 
							console.insertTextOut("The node \"" + selectedObjects +"\" was selected."); 
						} else if (console.wMode == windowMode.JOIN_RELATIONS) {
							
						} else if (console.wMode == HMLP_Console.windowMode.ADD_CLD){ 
							console.insertTextOut("The CLD \"" + selectedObjects +"\" was selected.");
						} else if (console.wMode == windowMode.LEARNING) { 
						} else if (console.wMode == windowMode.EVALUATION) { 
						}
					}
				}
			}
		});

		// Expand all
		for (int i = 0; i < tree.getRowCount(); i++)
			tree.expandRow(i);

		return new JScrollPane(tree);
	}
 
开发者ID:HML-UnBBayes,项目名称:hml,代码行数:56,代码来源:TreePanel_Right.java


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