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


Java TreeSelectionListener类代码示例

本文整理汇总了Java中javax.swing.event.TreeSelectionListener的典型用法代码示例。如果您正苦于以下问题:Java TreeSelectionListener类的具体用法?Java TreeSelectionListener怎么用?Java TreeSelectionListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: HintsPanel

import javax.swing.event.TreeSelectionListener; //导入依赖的package包/类
public HintsPanel(HintMetadata preselected, @NullAllowed final CustomizerContext<?, ?> cc, ClassPathBasedHintWrapper cpBased) {
    this.cpBased = cpBased;
    this.queryStatus = cc == null ? QueryStatus.NEVER : QueryStatus.SHOW_QUERIES;
    this.showHeavyInspections = true;
    init(null, true, false, false, false, cc == null, false, cc != null);
    select(preselected);
    configurationsPanel.setVisible(false);
    
    if (cc != null) {
        errorTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
            @Override public void valueChanged(TreeSelectionEvent e) {
                HintMetadata hm = getSelectedHint();

                if (hm != null) {
                    cc.setSelectedId(AnalyzerImpl.ID_JAVA_HINTS_PREFIX + hm.id);
                }
            }
        });
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:HintsPanel.java

示例2: AvailableTreeTable

import javax.swing.event.TreeSelectionListener; //导入依赖的package包/类
public AvailableTreeTable() {
	super();
	setTreeTableModel(new AvailableTreeTableModel(data.getRoot()));
	sizeColumns();
	setRowHeight(CELL_HEIGHT);
	setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	getTableHeader().setReorderingAllowed(false);

	addTreeSelectionListener(new TreeSelectionListener() {
		@Override
		public void valueChanged(TreeSelectionEvent e) {
			TreePath path = e.getPath();
			TreeTableNode node = (TreeTableNode) path.getLastPathComponent();
			if ("template".equals(node.getType())) {
				tempDownload.setEnabled(true);
			} else {
				tempDownload.setEnabled(false);
			}
		}
	});
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:22,代码来源:TemplateAddingPanel.java

示例3: OurTree

import javax.swing.event.TreeSelectionListener; //导入依赖的package包/类
/** Construct a Tree object with the given font size. */
public OurTree(int fontSize) {
	Font font = OurUtil.getVizFont().deriveFont((float) fontSize);
	OurTreeRenderer renderer = new OurTreeRenderer(fontSize);
	renderer.setFont(font);
	renderer.invalidate();
	renderer.validate();
	setRowHeight(0); // To allow variable row height on Mac OS X
	setCellRenderer(renderer);
	setFont(font);
	setBorder(new EmptyBorder(8, 8, 2, 2));
	getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
	putClientProperty("JTree.lineStyle", "Angled");
	setRootVisible(true);
	setForeground(Color.BLACK);
	setBackground(Color.WHITE);
	setOpaque(true);
	addTreeSelectionListener(new TreeSelectionListener() {
		public void valueChanged(TreeSelectionEvent e) {
			TreePath path = OurTree.this.getSelectionPath();
			if (path != null)
				OurTree.this.listeners.fire(OurTree.this, Listener.Event.CLICK, path.getLastPathComponent());
		}
	});
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:26,代码来源:OurTree.java

示例4: createInnerComponent

import javax.swing.event.TreeSelectionListener; //导入依赖的package包/类
protected void createInnerComponent() {
    panel.removeAll();
    Attribute[] attributes = getAttributes();
    RootCreater rootCreater = getRootCreater();

    component = new RowTreeTableComponent(engine, qualifier, accessRules,
            rootCreater, attributes, framework);

    rowSet = component.getRowSet();
    table = component.getTable();

    table.getTreeSelectionModel().addTreeSelectionListener(
            new TreeSelectionListener() {
                @Override
                public void valueChanged(TreeSelectionEvent e) {
                    refreshActions();
                }
            });
    refreshActions();
    panel.add(component, BorderLayout.CENTER);
    panel.revalidate();
    panel.repaint();
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:24,代码来源:AbstractTableView.java

示例5: OurTree

import javax.swing.event.TreeSelectionListener; //导入依赖的package包/类
/** Construct a Tree object with the given font size. */
public OurTree(int fontSize) {
   Font font = OurUtil.getVizFont().deriveFont((float)fontSize);
   OurTreeRenderer renderer = new OurTreeRenderer(fontSize);
   renderer.setFont(font);
   renderer.invalidate();
   renderer.validate();
   setRowHeight(0); // To allow variable row height on Mac OS X
   setCellRenderer(renderer);
   setFont(font);
   setBorder(new EmptyBorder(8, 8, 2, 2));
   getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
   putClientProperty("JTree.lineStyle", "Angled");
   setRootVisible(true);
   setForeground(Color.BLACK);
   setBackground(Color.WHITE);
   setOpaque(true);
   addTreeSelectionListener(new TreeSelectionListener() {
      public void valueChanged(TreeSelectionEvent e) {
         TreePath path = OurTree.this.getSelectionPath();
         if (path!=null) OurTree.this.listeners.fire(OurTree.this, Listener.Event.CLICK, path.getLastPathComponent());
      }
   });
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:25,代码来源:OurTree.java

示例6: FileTree

import javax.swing.event.TreeSelectionListener; //导入依赖的package包/类
/** Construct a FileTree */
 public FileTree(File dir) {
   setLayout(new BorderLayout());
   applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
   setBorder(null);

   // Make a tree list with all the nodes, and make it a JTree
   JTree tree = new JTree(addNodes(null, dir));
   tree.applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);

   // Add a listener
   tree.addTreeSelectionListener(new TreeSelectionListener() {
     public void valueChanged(TreeSelectionEvent e) {
       DefaultMutableTreeNode node = (DefaultMutableTreeNode) e
           .getPath().getLastPathComponent();
     }
   });

   add(BorderLayout.CENTER, tree);
   
   JScrollPane scrollBarExplorer = new JScrollPane();
   scrollBarExplorer.getViewport().add(tree);
   scrollBarExplorer.setBorder(null);
add(scrollBarExplorer, BorderLayout.CENTER);

 }
 
开发者ID:BlidiWajdi,项目名称:Mujeed-Arabic-Prolog,代码行数:27,代码来源:FileTree.java

示例7: ViewTreeGroups

import javax.swing.event.TreeSelectionListener; //导入依赖的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

示例8: NavigatorTopComponent

import javax.swing.event.TreeSelectionListener; //导入依赖的package包/类
public NavigatorTopComponent() {
    initComponents();

    tsl = new TreeSelectionListener() {
        @Override
        public void valueChanged(TreeSelectionEvent e) {
            TreePath path = e.getPath();
            if(path != null) processSelection(path);
        }
    };
    tree = new ProjectTree("root");
    jTree1.addTreeSelectionListener(tsl);
    DefaultMutableTreeNode root = new DefaultMutableTreeNode(tree.getRoot().getName());
    jTree1.setModel(new DefaultTreeModel(processNodes(root, tree.getRoot())));
    jTree1.setRootVisible(false);
    jTree1.revalidate();

    setName(Bundle.CTL_ProjectsTopComponent());
    setToolTipText(Bundle.HINT_ProjectsTopComponent());
    putClientProperty(TopComponent.PROP_CLOSING_DISABLED, Boolean.TRUE);
    putClientProperty(TopComponent.PROP_DRAGGING_DISABLED, Boolean.TRUE);
    putClientProperty(TopComponent.PROP_MAXIMIZATION_DISABLED, Boolean.TRUE);
    putClientProperty(TopComponent.PROP_SLIDING_DISABLED, Boolean.TRUE);
    putClientProperty(TopComponent.PROP_UNDOCKING_DISABLED, Boolean.TRUE);
    putClientProperty(TopComponent.PROP_KEEP_PREFERRED_SIZE_WHEN_SLIDED_IN, Boolean.TRUE);
}
 
开发者ID:Fidentis,项目名称:Analyst,代码行数:27,代码来源:NavigatorTopComponent.java

示例9: getTreeSelectionListener

import javax.swing.event.TreeSelectionListener; //导入依赖的package包/类
private TreeSelectionListener getTreeSelectionListener() {
	return new TreeSelectionListener() {
		@Override
		public void valueChanged( TreeSelectionEvent e ) {
			TreePath path = e.getPath();

			switch ( path.getPathCount() ) {
				case 1:
					//This shouldn't be possible because the root node is invisible.
					break;
				case 2:
					tablemodel.clear();
					break;
				case 3:
					DefaultMutableTreeNode dmtn = DefaultMutableTreeNode.class.cast( e.getPath().getLastPathComponent() );
					URI instance = URI.class.cast( dmtn.getUserObject() );
					ModelQueryAdapter mqa = ModelQueryAdapter.describe( instance );
					mqa.useInferred( false );
					tablemodel.setModel( engine.constructNoEx( mqa ) );
					break;
				default:
					break;
			}
		}
	};
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:27,代码来源:SemanticExplorerPanel.java

示例10: createView

import javax.swing.event.TreeSelectionListener; //导入依赖的package包/类
private void createView() {

		tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
		tree.addTreeSelectionListener(new TreeSelectionListener() {

			@Override
			public void valueChanged(TreeSelectionEvent e) {
				DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
				if (node == null) {
					return;
				}
				Object nodeInfo = node.getUserObject();
				if (node.isLeaf()) {
					switchView(nodeInfo.toString());
				}
			}
		});

		windowPane = new JPanel();
		windowPane.add(new TaskScreenPanel());
		JSplitPane pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, tree, windowPane);
		getContentPane().add(pane);
	}
 
开发者ID:metamug,项目名称:mtg-desktop-okhttp,代码行数:24,代码来源:ViewChecklist.java

示例11: setSelectionModel

import javax.swing.event.TreeSelectionListener; //导入依赖的package包/类
public void setSelectionModel(TreeSelectionModel selectionModel) {
		if (selectionModel == null)
			return;

		TreeSelectionModel oldValue = this.selectionModel;

		if (accessibleContext != null) {
			this.selectionModel
					.removeTreeSelectionListener((TreeSelectionListener) accessibleContext);
			selectionModel
					.addTreeSelectionListener((TreeSelectionListener) accessibleContext);
		}

		this.selectionModel = selectionModel;
//		firePropertyChange(SELECTION_MODEL_PROPERTY, oldValue, this.selectionModel);
	}
 
开发者ID:javalovercn,项目名称:j2se_for_android,代码行数:17,代码来源:JTree.java

示例12: setupTreeListener

import javax.swing.event.TreeSelectionListener; //导入依赖的package包/类
/**
 * Initialize tree properties and add listener.
 */
public void setupTreeListener(){
    libTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    libTree.addTreeSelectionListener(new TreeSelectionListener() {
        public void valueChanged(TreeSelectionEvent e) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode)
                    libTree.getLastSelectedPathComponent();
            if (node == null)
                return;

            if (!node.children().hasMoreElements()) {
                Method m = methodCache.get(node.getUserObject());
                if (m != null){
                    callFrame.createParameterList(m);
                    callFrame.setVisible(true);
                }
            }
        }
    });
}
 
开发者ID:m4dguy,项目名称:CVForge,代码行数:23,代码来源:CVForgeFrame.java

示例13: addTreeListener

import javax.swing.event.TreeSelectionListener; //导入依赖的package包/类
private void addTreeListener() {
	for (int i = 1; i < tree.getRowCount(); i++) {
		tree.setSelectionRow(i);
		if (selected.equals(lastSelected)) {
			break;
		}
	}
	tree.addTreeSelectionListener(new TreeSelectionListener() {
		@Override
		public void valueChanged(TreeSelectionEvent e) {
			node = (IconNode) e.getPath().getLastPathComponent();
			updateVariableChoices(node,null);
		}
	});
	tree.setSelectionRow(0);
}
 
开发者ID:MyersResearchGroup,项目名称:iBioSim,代码行数:17,代码来源:Graph.java

示例14: getCatComponent

import javax.swing.event.TreeSelectionListener; //导入依赖的package包/类
/**
 * return category tree with filtered child nodes
 */
public JComponent getCatComponent(EventListener listener) {
    if(isFilterEnabled() && ((filteredCatTree == null) || (getLastUpdated() < PrefManager.get().getFiltersLastChanged()))) {
        // first refresh filter checker with current filters
        setFilterChecker(FilterChecker.getFilterChecker());
        
        // apply new filter settings.
        filteredCatTree = new JTree(filterNodes(getRootNode()));
        if(getName().startsWith("Monitors") || getName().startsWith("Threads blocked by Monitors")) {
            filteredCatTree.setShowsRootHandles(true);
        }
        filteredCatTree.setCellRenderer(new TreeRenderer());
        filteredCatTree.setRootVisible(false);
        filteredCatTree.addTreeSelectionListener((TreeSelectionListener) listener);
        setLastUpdated();
    } else if (!isFilterEnabled() && (filteredCatTree == null) || (getLastUpdated() < PrefManager.get().getFiltersLastChanged())) {
        filteredCatTree = new JTree(getRootNode());
        if(getName().startsWith("Monitors") || getName().startsWith("Threads blocked by Monitors")) {
            filteredCatTree.setShowsRootHandles(true);
        }
        filteredCatTree.setCellRenderer(new TreeRenderer());
        filteredCatTree.setRootVisible(false);
        filteredCatTree.addTreeSelectionListener((TreeSelectionListener) listener);
    }
    return(filteredCatTree);
}
 
开发者ID:irockel,项目名称:tda,代码行数:29,代码来源:TreeCategory.java

示例15: addSelectionListeners

import javax.swing.event.TreeSelectionListener; //导入依赖的package包/类
/** 
 * Adds the listeners that manage selection synchronization in this tree. 
 */
private void addSelectionListeners(final FurnitureCatalog catalog, final FurnitureCatalogController controller)
{
	final SelectionListener modelSelectionListener = new SelectionListener()
	{
		public void selectionChanged(SelectionEvent selectionEvent)
		{
			updateTreeSelectedFurniture(catalog, controller);
		}
	};
	this.treeSelectionListener = new TreeSelectionListener()
	{
		public void valueChanged(TreeSelectionEvent ev)
		{
			// Updates selected furniture in catalog from selected nodes in tree. 
			controller.removeSelectionListener(modelSelectionListener);
			controller.setSelectedFurniture(getSelectedFurniture());
			controller.addSelectionListener(modelSelectionListener);
		}
	};
	
	controller.addSelectionListener(modelSelectionListener);
	getSelectionModel().addTreeSelectionListener(this.treeSelectionListener);
}
 
开发者ID:valsr,项目名称:SweetHome3D,代码行数:27,代码来源:FurnitureCatalogTree.java


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