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


Java JTree.setCellEditor方法代码示例

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


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

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


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