本文整理汇总了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();
}