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


Java JTree.setRootVisible方法代码示例

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


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

示例1: createLeftPanel

import javax.swing.JTree; //导入方法依赖的package包/类
private synchronized Component createLeftPanel() {
    SampleResult rootSampleResult = new SampleResult();
    rootSampleResult.setSampleLabel("Root");
    rootSampleResult.setSuccessful(true);
    root = new SearchableTreeNode(rootSampleResult, null);

    treeModel = new DefaultTreeModel(root);
    jTree = new JTree(treeModel);
    jTree.setCellRenderer(new ResultsNodeRenderer());
    jTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    jTree.addTreeSelectionListener(this);
    jTree.setRootVisible(false);
    jTree.setShowsRootHandles(true);
    JScrollPane treePane = new JScrollPane(jTree);
    treePane.setPreferredSize(new Dimension(200, 300));

    VerticalPanel leftPane = new VerticalPanel();
    leftPane.add(treePane, BorderLayout.CENTER);
    leftPane.add(createComboRender(), BorderLayout.NORTH);
    autoScrollCB = new JCheckBox(JMeterUtils.getResString("view_results_autoscroll")); // $NON-NLS-1$
    autoScrollCB.setSelected(false);
    autoScrollCB.addItemListener(this);
    leftPane.add(autoScrollCB, BorderLayout.SOUTH);
    return leftPane;
}
 
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:26,代码来源:ViewResultsFullVisualizer.java

示例2: manipulateJTree

import javax.swing.JTree; //导入方法依赖的package包/类
/**
 * This method aids in the creation of the JTrees which are used to add in
 * the JTabbedPane component
 *
 * @param top
 *            - input to the JTree which will be formatted for display
 * @return JTree which will be used for adding to the root of a pane
 */
private JTree manipulateJTree(final DefaultMutableTreeNode top) {
	final JTree resultsTree = new JTree(top) {
		private static final long serialVersionUID = 1748421292182815368L;

		@Override
		public Insets getInsets() {
			return new Insets(5, 5, 5, 5);
		}
	};

	resultsTree.setRootVisible(false);
	resultsTree.setShowsRootHandles(true);

	if (resultsTree.getRowCount() > 0) {
		resultsTree.expandRow(0);
	}

	return resultsTree;
}
 
开发者ID:orionhealth,项目名称:rlc-analyser,代码行数:28,代码来源:RLCTreeBuilder.java

示例3: SwingSpyPanel

import javax.swing.JTree; //导入方法依赖的package包/类
/**
	 * Initialization.
	 */
	public SwingSpyPanel() {
		setPreferredSize(new Dimension(INITIAL_WIDTH, INITIAL_HEIGHT));
		setLayout(new BorderLayout());

		root = new DefaultMutableTreeNode();
		componentTree = new JTree(root);
		componentTree.setRootVisible(false);
		componentTree.setCellRenderer(new SwingComponentRenderer());
		componentTree.addTreeSelectionListener(new CustomSelectionListener());
//		add(new JScrollPane(componentTree), BorderLayout.CENTER);

		detailsData = new JEditorPane();
		detailsData.setBackground(new Color(250, 250, 250));
		detailsData.setForeground(new Color(33, 33, 33));
		detailsData.setBorder(BorderFactory.createLineBorder(new Color(100, 100, 244), 1));
		detailsData.setPreferredSize(new Dimension(150, INITIAL_HEIGHT));
		detailsData.setEditable(false);
		detailsData.setContentType("text/html");
		SwingUtil.enforceJEditorPaneFont(detailsData, font);
		detailsScrollPane = new JScrollPane(detailsData);
//		add(detailsScrollPane, BorderLayout.EAST);

		JSplitPane hPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(componentTree), detailsScrollPane);
		hPane.setContinuousLayout(true);
		hPane.setOneTouchExpandable(true);
		hPane.setDividerLocation(INITIAL_WIDTH - 200);
		add(hPane, BorderLayout.CENTER);

		componentData = new JEditorPane();
		componentData.setBackground(new Color(250, 250, 250));
		componentData.setForeground(new Color(33, 33, 33));
		componentData.setBorder(BorderFactory.createLineBorder(new Color(100, 100, 244), 1));
		componentData.setPreferredSize(new Dimension(INITIAL_WIDTH, 36));
		componentData.setEditable(false);
		componentData.setContentType("text/html");
		SwingUtil.enforceJEditorPaneFont(componentData, font);
		add(componentData, BorderLayout.SOUTH);

	}
 
开发者ID:igr,项目名称:swingspy,代码行数:43,代码来源:SwingSpyPanel.java

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

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

示例6: buildTree

import javax.swing.JTree; //导入方法依赖的package包/类
/**
 * Builds the JTree which represents the navigation menu and then returns it
 *
 * @return The navigation tree.
 */
private JTree buildTree() {
    String name = Messages.message("colopedia");
    DefaultMutableTreeNode root
        = new DefaultMutableTreeNode(new ColopediaTreeItem(null, null, name, null));

    FreeColClient fcc = getFreeColClient();
    new TerrainDetailPanel(fcc, this).addSubTrees(root);
    new ResourcesDetailPanel(fcc, this).addSubTrees(root);
    new GoodsDetailPanel(fcc, this).addSubTrees(root);
    new UnitDetailPanel(fcc, this).addSubTrees(root);
    new BuildingDetailPanel(fcc, this).addSubTrees(root);
    new FatherDetailPanel(fcc, this).addSubTrees(root);
    new NationDetailPanel(fcc, this).addSubTrees(root);
    new NationTypeDetailPanel(fcc, this).addSubTrees(root);
    new ConceptDetailPanel(fcc, this).addSubTrees(root);

    DefaultTreeModel treeModel = new DefaultTreeModel(root);
    tree = new JTree(treeModel) {
            @Override
            public Dimension getPreferredSize() {
                return new Dimension(
                    (int)(200 * getImageLibrary().getScaleFactor()),
                    super.getPreferredSize().height);
            }
        };
    tree.setRootVisible(false);
    tree.setCellRenderer(new ColopediaTreeCellRenderer());
    tree.setOpaque(false);
    tree.addTreeSelectionListener(this);

    listPanel.add(tree);
    Enumeration allNodes = root.depthFirstEnumeration();
    while (allNodes.hasMoreElements()) {
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) allNodes.nextElement();
        ColopediaTreeItem item = (ColopediaTreeItem) node.getUserObject();
        nodeMap.put(item.getId(), node);
    }
    return tree;
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:45,代码来源:ColopediaPanel.java

示例7: getContent

import javax.swing.JTree; //导入方法依赖的package包/类
private JScrollPane getContent() {
    jTree = new JTree(getTreeModel());
    jTree.setRootVisible(false);
    jTree.setDragEnabled(true);
    jTree.setDropMode(DropMode.INSERT);
    jTree.setTransferHandler(new TreeTransferHandler());
    jTree.getSelectionModel().setSelectionMode(
            TreeSelectionModel.SINGLE_TREE_SELECTION);
    expandTree(jTree);
    return new JScrollPane(jTree);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:LastNodeLowerHalfDrop.java

示例8: init

import javax.swing.JTree; //导入方法依赖的package包/类
void init(String layersXMLName) throws IOException {
		Vector layers = ParseLink.parse(URLFactory.url(haxby.map.MapApp.TEMP_BASE_URL + "GMA/Layers/" + layersXMLName));
	//	ParseLink.printProperties( layers, 0);
		rootEntry = new LayerEntry(null, new Vector(), "layers", "", null);
		layers = ParseLink.getProperties( layers, "layer");
		for( int i=0 ; i<layers.size() ; i++) {
			addLayers( (Vector)layers.get(i), rootEntry);
		}
		layerTree = new JTree(rootEntry);
		layerTree.setRootVisible(false);
		layerTree.setShowsRootHandles(true);
/*
		layerTree.addMouseListener( new MouseAdapter() {
			public void mouseReleased(MouseEvent e) {
				if(e.isPopupTrigger()) {
					popup(e);
				}
			}
			public void mousePressed(MouseEvent e) {
				if(e.isPopupTrigger()) {
					popup(e);
				}
			}
		});
*/
		renderer = new JLabel("");
		renderer.setOpaque(true);
	//	layerTree.setCellRenderer(this);
	//	layerTree.setBackground( new Color(215,215,215) );
		renderer.setBackground( new Color(225,225,255) );
		pop = new JPopupMenu();
		popLabel = new JLabel("");
		popLabel.setHorizontalAlignment( JLabel.CENTER );
		on = new JCheckBoxMenuItem( "display");
		pop.add( popLabel );
		pop.addSeparator();
		pop.add( on );
		pop.add( "edit properties");
	}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:40,代码来源:LayerModel.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: setupGUI

import javax.swing.JTree; //导入方法依赖的package包/类
private void setupGUI()
{
	// Create Components
	fileTreeModel = new CustomTreeModel(new DefaultMutableTreeNode("Loading..."));
	fileTree = new JTree(fileTreeModel);
	fileTree.setRootVisible(false);
	fileTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
	fileTree.addTreeSelectionListener(new TreeSelectionListener()
	{
		@Override
		public void valueChanged(TreeSelectionEvent e)
		{
			DefaultMutableTreeNode node = (DefaultMutableTreeNode) fileTree.getLastSelectedPathComponent();
			if( node == null )
			{
				btnEnable(true, false, true, false);
			}
			else
			{
				if( !node.getAllowsChildren() )
				{
					btnEnable(true, true, true, true);
				}
				else
				{
					btnEnable(true, false, true, true);
				}
			}
		}
	});

	// Holds all the action buttons
	setLayout(new MigLayout("insets 0, fill, wrap 2", "[fill][fill,grow]", "[][][][][][][grow]"));

	uploadFile = new JButton(s("button.upload"));
	add(uploadFile);
	uploadFile.addActionListener(uploadFileListener);

	// Add to layout
	add(new JScrollPane(fileTree), "spany 7, growy");

	downloadFile = new JButton(s("button.download"));
	add(downloadFile);
	downloadFile.addActionListener(downloadFileListener);

	add(new JSeparator());

	createFolder = new JButton(s("button.newfolder"));
	add(createFolder);
	createFolder.addActionListener(createFolderListener);

	add(new JSeparator());

	delete = new JButton(s("button.delete"));
	add(delete);
	delete.addActionListener(deleteFileFolderListener);

	// Disable all buttons
	btnEnable(true, false, true, false);
}
 
开发者ID:equella,项目名称:Equella,代码行数:61,代码来源:EntityStagingFileViewer.java

示例11: createQualifiersList

import javax.swing.JTree; //导入方法依赖的package包/类
private Component createQualifiersList() {

        // Load tree with elements meta data standard system qualifier.

        RowSet rowSet = new RowSet(engine, StandardAttributesPlugin
                .getQualifiersQualifier(engine), new Attribute[]{});

        final JTree qualifiersTree = new JTree(new DefaultTreeModel(rowSet
                .getRoot()));

        qualifiersTree.setRootVisible(false);

        qualifiersTree.getSelectionModel().addTreeSelectionListener(
                new TreeSelectionListener() {

                    RowSet rowSet = null;

                    @Override
                    public void valueChanged(TreeSelectionEvent e) {
                        // Load elements of qualifier.
                        // We will load elements with RowSet class,
                        // you can also load elements with engne.getElements
                        // methods.
                        Object value = qualifiersTree.getSelectionPath()
                                .getLastPathComponent();
                        // Value is really a Row element.
                        if (value != null) {
                            if (rowSet != null) {// If rowSet is opened, we
                                // should close it and free
                                // all listeners.
                                rowSet.close();
                                rowSet = null;// Just in case :)
                            }
                            Row qualifierRow = (Row) value;
                            // Even you are not going to use any attribute,
                            // use RowSet(Engine, Qualifier Attribute[])
                            // constructor
                            // instead of RowSet(Engine, Qualifier) constructor.
                            rowSet = new RowSet(engine,
                                    StandardAttributesPlugin.getQualifier(
                                            engine, qualifierRow.getElement()),
                                    new Attribute[]{});

                            // And just load tree component with elements
                            // covered to Row objects.
                            tree
                                    .setModel(new DefaultTreeModel(rowSet
                                            .getRoot()));
                        }
                    }
                });

        JScrollPane pane = new JScrollPane();

        pane.setViewportView(qualifiersTree);

        return pane;
    }
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:59,代码来源:RSFViewer2.java


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