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


Java JTree.addMouseListener方法代码示例

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


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

示例1: buildTree

import javax.swing.JTree; //导入方法依赖的package包/类
/**
 * 
 */
private void buildTree() {
    DefaultMutableTreeNode root = new DefaultMutableTreeNode("user");
    tree = new JTree(root);
    tree.putClientProperty("JTree.lineStyle", "Angled");
    tree.setCellRenderer(new NavigationTreeCellRenderer());
    tree.setShowsRootHandles(true);
    
    DefaultTreeSelectionModel model = new DefaultTreeSelectionModel();
    model.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    
    graphsCategory = new DefaultMutableTreeNode("graphs");
    
    mouseAdapter = new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            itemSelected(e);
        }
    };
    tree.addMouseListener(mouseAdapter);
    
    root.add(graphsCategory);        
    loadGraphs();
}
 
开发者ID:guilhebl,项目名称:routerapp,代码行数:26,代码来源:NavigationView.java

示例2: connect

import javax.swing.JTree; //导入方法依赖的package包/类
void connect( JTree errorTree, DefaultTreeModel errModel, JComboBox severityComboBox, 
              JCheckBox tasklistCheckBox, JPanel customizerPanel,
              JEditorPane descriptionTextArea) {
    
    this.errorTree = errorTree;
    this.errModel = errModel;
    this.severityComboBox = severityComboBox;
    this.tasklistCheckBox = tasklistCheckBox;
    this.customizerPanel = customizerPanel;
    this.descriptionTextArea = descriptionTextArea;        
    
    valueChanged( null );
    
    errorTree.addKeyListener(this);
    errorTree.addMouseListener(this);
    errorTree.getSelectionModel().addTreeSelectionListener(this);
        
    severityComboBox.addActionListener(this);
    tasklistCheckBox.addChangeListener(this);
    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:HintsPanelLogic.java

示例3: connect

import javax.swing.JTree; //导入方法依赖的package包/类
void connect( JTree errorTree, JComboBox severityComboBox, 
              JCheckBox tasklistCheckBox, JPanel customizerPanel,
              JEditorPane descriptionTextArea) {
    
    this.errorTree = errorTree;
    this.severityComboBox = severityComboBox;
    this.tasklistCheckBox = tasklistCheckBox;
    this.customizerPanel = customizerPanel;
    this.descriptionTextArea = descriptionTextArea;        
    
    valueChanged( null );
    
    errorTree.addKeyListener(this);
    errorTree.addMouseListener(this);
    errorTree.getSelectionModel().addTreeSelectionListener(this);
        
    severityComboBox.addActionListener(this);
    tasklistCheckBox.addChangeListener(this);
    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:HintsPanelLogic.java

示例4: SimulationExplorer

import javax.swing.JTree; //导入方法依赖的package包/类
SimulationExplorer(Project proj, MenuListener menu) {
	super(new BorderLayout());
	this.project = proj;

	SimulationToolbarModel toolbarModel = new SimulationToolbarModel(proj, menu);
	Toolbar toolbar = new Toolbar(toolbarModel);
	add(toolbar, BorderLayout.NORTH);

	model = new SimulationTreeModel(proj.getSimulator().getCircuitState());
	model.setCurrentView(project.getCircuitState());
	tree = new JTree(model);
	tree.setCellRenderer(new SimulationTreeRenderer());
	tree.addMouseListener(this);
	tree.setToggleClickCount(3);
	add(new JScrollPane(tree), BorderLayout.CENTER);
	proj.addProjectListener(this);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:18,代码来源:SimulationExplorer.java

示例5: connect

import javax.swing.JTree; //导入方法依赖的package包/类
void connect( final JTree errorTree, DefaultTreeModel errorTreeModel, JLabel severityLabel, JComboBox severityComboBox,
              JCheckBox tasklistCheckBox, JPanel customizerPanel,
              JEditorPane descriptionTextArea, final JComboBox configCombo, JButton editScript,
              HintsSettings settings, boolean direct) {
    
    this.errorTree = errorTree;
    this.errorTreeModel = errorTreeModel;
    this.severityLabel = severityLabel;
    this.severityComboBox = severityComboBox;
    this.tasklistCheckBox = tasklistCheckBox;
    this.customizerPanel = customizerPanel;
    this.descriptionTextArea = descriptionTextArea;        
    this.configCombo = configCombo;
    this.editScript = editScript;
    this.direct = direct;
    
    if (configCombo.getSelectedItem() !=null) {
        originalSettings = ((Configuration) configCombo.getSelectedItem()).getSettings();
    } else if (settings != null) {
        originalSettings = settings;
    } else {
        originalSettings = HintsSettings.getGlobalSettings();
    }
    
    writableSettings = new WritableSettings(originalSettings, direct);
    
    valueChanged( null );
    
    errorTree.addKeyListener(this);
    errorTree.addMouseListener(this);
    errorTree.getSelectionModel().addTreeSelectionListener(this);
        
    this.configCombo.addItemListener(this);
    severityComboBox.addActionListener(this);
    tasklistCheckBox.addChangeListener(this);
    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:38,代码来源:HintsPanelLogic.java

示例6: ExtendedCheckTreeMouseSelectionManager

import javax.swing.JTree; //导入方法依赖的package包/类
public ExtendedCheckTreeMouseSelectionManager(JTree tree, boolean selectAll) {
	this.tree = tree;
	selectionModel = new ExtendedCheckTreeSelectionModel(tree.getModel());

	if (selectAll) {
		selectionModel.addSelectionPath(tree.getPathForRow(0));
	}

	tree.setCellRenderer(new ExtendedCheckTreeCellRenderer(new DefaultTreeCellRenderer(), selectionModel));
	tree.addMouseListener(this);
	selectionModel.addTreeSelectionListener(this);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:13,代码来源:ExtendedCheckTreeMouseSelectionManager.java

示例7: TreePanel

import javax.swing.JTree; //导入方法依赖的package包/类
public TreePanel()
{
	query = new JTextField();
	query.addActionListener(this);

	search = new JButton(CurrentLocale.get("searching.userGroupRole.executeQuery"));
	search.addActionListener(this);

	JPanel panel = new JPanel();
	panel.setLayout(new BorderLayout(5, 5));
	panel
		.add(new JLabel(CurrentLocale.get("com.tle.admin.recipients.browserfinder.groups")), BorderLayout.WEST);
	panel.add(query, BorderLayout.CENTER);
	panel.add(search, BorderLayout.EAST);

	model = new DefaultTreeModel(null);
	tree = new JTree(model);

	setLayout(new BorderLayout(5, 5));
	add(panel, BorderLayout.NORTH);
	add(new JScrollPane(tree), BorderLayout.CENTER);

	tree.addMouseListener(mouse);
	tree.setShowsRootHandles(true);
	tree.setRootVisible(false);
	tree.addTreeSelectionListener(this);
}
 
开发者ID:equella,项目名称:Equella,代码行数:28,代码来源:BrowseFinder.java

示例8: 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

示例9: createDocPane

import javax.swing.JTree; //导入方法依赖的package包/类
private JTree createDocPane() {
    final DefaultMutableTreeNode root = new DefaultMutableTreeNode();
    for (Map.Entry<?,? extends List<?>> docEntry : getDoc().getItemTree()
        .entrySet()) {
        DefaultMutableTreeNode node = new DefaultMutableTreeNode(docEntry.getKey());
        root.add(node);
        for (Object rule : docEntry.getValue()) {
            node.add(new DefaultMutableTreeNode(rule));
        }
    }
    final JTree result = new JTree(root) {
        @Override
        public String getToolTipText(MouseEvent evt) {
            if (getRowForLocation(evt.getX(), evt.getY()) == -1) {
                return null;
            }
            TreePath curPath = getPathForLocation(evt.getX(), evt.getY());
            Object userObject =
                ((DefaultMutableTreeNode) curPath.getLastPathComponent()).getUserObject();
            return getToolTip(userObject);
        }
    };
    result.setRootVisible(false);
    result.setShowsRootHandles(true);
    DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) result.getCellRenderer();
    renderer.setBackgroundNonSelectionColor(null);
    renderer.setBackgroundSelectionColor(null);
    renderer.setTextSelectionColor(null);
    renderer.setLeafIcon(null);
    renderer.setClosedIcon(null);
    renderer.setOpenIcon(null);
    result.setCellRenderer(renderer);
    ToolTipManager.sharedInstance()
        .registerComponent(result);
    result.addMouseListener(new DismissDelayer(result));
    for (int i = 0; i < root.getChildCount(); i++) {
        result
            .expandPath(new TreePath(((DefaultMutableTreeNode) root.getChildAt(i)).getPath()));
    }
    result.setBackground(null);
    return result;
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:43,代码来源:ControlDisplay.java

示例10: initialise

import javax.swing.JTree; //导入方法依赖的package包/类
public void initialise(boolean allowReordering, int fixedEditorWidth)
{
	additionalActions = getAdditionalActions();
	if( additionalActions == null )
	{
		additionalActions = Collections.emptyList();
	}

	upDownActions = new ArrayList<TLEAction>();
	if( allowReordering )
	{
		upDownActions.add(upAction);
		upDownActions.add(downAction);
	}

	editorContainer = new JPanel(new GridLayout(1, 1));
	editorContainer.setBorder(AppletGuiUtils.DEFAULT_BORDER);
	editorContainer.add(getNoSelectionComponent());

	tree = new JTree(model.getUnderlyingTreeModel());
	tree.addMouseListener(new TreePopupListener(tree, new CombinedCollection<TLEAction>(additionalActions,
		upDownActions)));
	tree.addTreeSelectionListener(new TreeSelectionListener()
	{
		@Override
		public void valueChanged(TreeSelectionEvent e)
		{
			NODE_TYPE newSelection = getCurrentTreeSelection();
			if( !Objects.equals(currentSelection, newSelection) )
			{
				saveCurrentSelection();
				loadCurrentSelection();

				update();
			}
		}
	});

	JScrollPane treeScroller = new JScrollPane(tree);

	JComponent buttonsPanel = getButtonsPanel();

	JButton upButton = new JTextlessButton(upAction);
	JButton downButton = new JTextlessButton(downAction);

	final int height1 = upButton.getPreferredSize().height;
	final int height2 = buttonsPanel.getPreferredSize().height;
	final int width1 = upButton.getPreferredSize().width;
	final int width2 = fixedEditorWidth >= 0 ? TableLayout.FILL : buttonsPanel.getPreferredSize().width;
	final int width3 = fixedEditorWidth >= 0 ? fixedEditorWidth : TableLayout.FILL;

	final int[] rows = {TableLayout.FILL, height1, height1, TableLayout.FILL, height2,};
	final int[] cols = allowReordering ? new int[]{width1, width2, width3,} : new int[]{width2, width3,};

	setLayout(new TableLayout(rows, cols));

	int columnStart = 0;
	if( allowReordering )
	{
		columnStart = 1;
		add(upButton, new Rectangle(0, 1, 1, 1));
		add(downButton, new Rectangle(0, 2, 1, 1));
	}
	add(treeScroller, new Rectangle(columnStart, 0, 1, 4));
	add(buttonsPanel, new Rectangle(columnStart, 4, 1, 1));
	add(editorContainer, new Rectangle(columnStart + 1, 0, 1, 4));

	update();
}
 
开发者ID:equella,项目名称:Equella,代码行数:70,代码来源:AbstractTreeWithView.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()) {

					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

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