當前位置: 首頁>>代碼示例>>Java>>正文


Java JTree.setCellRenderer方法代碼示例

本文整理匯總了Java中javax.swing.JTree.setCellRenderer方法的典型用法代碼示例。如果您正苦於以下問題:Java JTree.setCellRenderer方法的具體用法?Java JTree.setCellRenderer怎麽用?Java JTree.setCellRenderer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.JTree的用法示例。


在下文中一共展示了JTree.setCellRenderer方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: 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

示例3: InfrastructureBrowserPanel

import javax.swing.JTree; //導入方法依賴的package包/類
/**
 * 
 */
public InfrastructureBrowserPanel() {
	setLayout(new BorderLayout(0, 0));

	final JPanel panel = new JPanel();
	add(panel, BorderLayout.SOUTH);

	btnRefresh = new JButton("Refresh");
	panel.add(btnRefresh);

	final JScrollPane scrollPane = new JScrollPane();
	scrollPane.setPreferredSize(new Dimension(600, 500));
	add(scrollPane, BorderLayout.CENTER);
	model = new InfrastructureTreeModel(new ArrayList<ClusterInfo>());
	tree = new JTree(model);
	tree.setCellRenderer(new InfrastructureCellRenderer(tree
			.getCellRenderer()));
	scrollPane.setViewportView(tree);
}
 
開發者ID:roscisz,項目名稱:KernelHive,代碼行數:22,代碼來源:InfrastructureBrowserPanel.java

示例4: UpdateUIRecursionTest

import javax.swing.JTree; //導入方法依賴的package包/類
public UpdateUIRecursionTest() {
    super("UpdateUIRecursionTest");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setSize(400, 400);

    String[] listData = {
        "First", "Second", "Third", "Fourth", "Fifth", "Sixth"
    };

    tree = new JTree(listData);
    renderer = new DefaultTreeCellRenderer();
    getContentPane().add(new JScrollPane(tree), BorderLayout.CENTER);
    tree.setCellRenderer(this);

    setVisible(true);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:17,代碼來源:UpdateUIRecursionTest.java

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

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

示例8: buildMainPanel

import javax.swing.JTree; //導入方法依賴的package包/類
protected Component buildMainPanel() {
  JPanel keyPanel = buildKeyTablePanel();

  /*
   * Tree of all components from target component down
   */
  JPanel treePanel = new JPanel(new BorderLayout());
  MyTreeNode top = new MyTreeNode(target);
  createNodes(top);
  tree = new JTree(top);
  tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
  tree.addTreeSelectionListener(this);
  tree.setSelectionRow(0);
  tree.setCellRenderer(new MyTreeCellRenderer());
  JScrollPane treeScroll = new JScrollPane(tree, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
      JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
  treePanel.add(treeScroll, BorderLayout.CENTER);
  treePanel.setMinimumSize(new Dimension(400, 100));
  treePanel.setPreferredSize(new Dimension(800, 300));

  /*
   * First split between Tree display and Keys
   */
  JSplitPane split1 = new JSplitPane(JSplitPane.VERTICAL_SPLIT, treePanel, keyPanel);
  split1.setResizeWeight(0.5);

  return split1;
}
 
開發者ID:ajmath,項目名稱:VASSAL-src,代碼行數:29,代碼來源:TranslateWindow.java

示例9: setupGui

import javax.swing.JTree; //導入方法依賴的package包/類
private void setupGui(ClientService clientService, PluginService pluginService)
{
	model = new SecurityTreeModel(clientService, pluginService);

	tree = new JTree(model);
	tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
	tree.setCellRenderer(new MyTreeCellRenderer());
	tree.addTreeSelectionListener(this);

	tabManager = new TabManager(clientService, allowEditing);

	JScrollPane scroller = new JScrollPane(tree);
	scroller.setMinimumSize(new Dimension(200, Integer.MAX_VALUE));

	JSplitPane split = AppletGuiUtils.createSplitPane();
	split.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
	split.setContinuousLayout(true);
	split.add(scroller, JSplitPane.LEFT);
	split.add(tabManager, JSplitPane.RIGHT);

	JButton closeButton = new JButton(closeAction);

	final int[] rows = {TableLayout.FILL, closeButton.getPreferredSize().height,};
	final int[] cols = {TableLayout.FILL, closeButton.getPreferredSize().width,};

	content = new JPanel(new TableLayout(rows, cols));
	content.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
	content.add(split, new Rectangle(0, 0, 2, 1));
	content.add(closeButton, new Rectangle(1, 1, 1, 1));

	updateEditor();
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:33,代碼來源:SecurityTree.java

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

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

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

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

示例14: initializeTree

import javax.swing.JTree; //導入方法依賴的package包/類
private void initializeTree() {
    tree = new JTree();
    tree.setCellRenderer(new CustomTreeRenderer());
    tree.setVisibleRowCount(8);
    tree.setBackground(background);
    tree.addTreeSelectionListener(this);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    tree.setShowsRootHandles(true);

}
 
開發者ID:bcgov,項目名稱:sbc-qsystem,代碼行數:11,代碼來源:JTreeComboBox.java

示例15: TreeIconDemo

import javax.swing.JTree; //導入方法依賴的package包/類
public TreeIconDemo() {
    super(new GridLayout(1, 0));

    // Create the nodes.
    DefaultMutableTreeNode top = new DefaultMutableTreeNode("The Java Series");
    createNodes(top);

    // Create a tree that allows one selection at a time.
    tree = new JTree(top);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);

    // Set the icon for leaf nodes.
    ImageIcon leafIcon = createImageIcon("images/middle.gif");
    if (leafIcon != null) {
        DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
        renderer.setLeafIcon(leafIcon);
        tree.setCellRenderer(renderer);
    } else {
        System.err.println("Leaf icon missing; using default.");
    }

    // Listen for when the selection changes.
    tree.addTreeSelectionListener(this);

    // Create the scroll pane and add the tree to it.
    JScrollPane treeView = new JScrollPane(tree);

    // Create the HTML viewing pane.
    htmlPane = new JEditorPane();
    htmlPane.setEditable(false);
    initHelp();
    JScrollPane htmlView = new JScrollPane(htmlPane);

    // Add the scroll panes to a split pane.
    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    splitPane.setTopComponent(treeView);
    splitPane.setBottomComponent(htmlView);

    Dimension minimumSize = new Dimension(100, 50);
    htmlView.setMinimumSize(minimumSize);
    treeView.setMinimumSize(minimumSize);
    splitPane.setDividerLocation(100); // XXX: ignored in some releases
                                       // of Swing. bug 4101306
    // workaround for bug 4101306:
    // treeView.setPreferredSize(new Dimension(100, 100));

    splitPane.setPreferredSize(new Dimension(500, 300));

    // Add the split pane to this panel.
    add(splitPane);
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:52,代碼來源:TreeIconDemo.java


注:本文中的javax.swing.JTree.setCellRenderer方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。