本文整理汇总了Java中javax.swing.tree.DefaultTreeSelectionModel.setSelectionMode方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultTreeSelectionModel.setSelectionMode方法的具体用法?Java DefaultTreeSelectionModel.setSelectionMode怎么用?Java DefaultTreeSelectionModel.setSelectionMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.tree.DefaultTreeSelectionModel
的用法示例。
在下文中一共展示了DefaultTreeSelectionModel.setSelectionMode方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildTree
import javax.swing.tree.DefaultTreeSelectionModel; //导入方法依赖的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();
}
示例2: OntologyBrowser
import javax.swing.tree.DefaultTreeSelectionModel; //导入方法依赖的package包/类
public OntologyBrowser(OWLOntology ontology, Set<String> rootsToRemove) {
super();
this.ontology = ontology;
this.rootConcept = "Thing";
this.buildTreeModel();
for (String concept : rootsToRemove) {
DefaultMutableTreeNode node = getNodeFromName(concept);
this.dtm.removeNodeFromParent(node);
}
this.setModel(this.dtm);
// set the tree selection model
DefaultTreeSelectionModel dtsm = new DefaultTreeSelectionModel();
dtsm.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
this.setSelectionModel(dtsm);
// set the tree renderer
OntologyRenderer myRenderer = new OntologyRenderer();
this.setCellRenderer(myRenderer);
this.setRootVisible(false);
}
示例3: PullRequestsTreeModel
import javax.swing.tree.DefaultTreeSelectionModel; //导入方法依赖的package包/类
public PullRequestsTreeModel() {
super(null);
this.root = new PRTreeNode(TfPluginBundle.message(TfPluginBundle.KEY_VCS_PR_TITLE));
setRoot(root);
this.requestedByMeRoot = new PRTreeNode(TfPluginBundle.message(TfPluginBundle.KEY_VCS_PR_REQUESTED_BY_ME));
root.insert(requestedByMeRoot, 0);
this.assignedToMeRoot = new PRTreeNode(TfPluginBundle.message(TfPluginBundle.KEY_VCS_PR_ASSIGNED_TO_ME));
root.insert(assignedToMeRoot, 1);
allRequestedByMePullRequests = new ArrayList<GitPullRequest>();
allAssignedToMePullRequests = new ArrayList<GitPullRequest>();
selectionModel = new DefaultTreeSelectionModel();
selectionModel.setSelectionMode(DefaultTreeSelectionModel.SINGLE_TREE_SELECTION);
}
示例4: init
import javax.swing.tree.DefaultTreeSelectionModel; //导入方法依赖的package包/类
private void init() {
editor = new ProcessEditor();
editor.setModel(form);
editor.setAnimationEnabled(true);
editorPane.setLayout(new GridLayout(1,1));
editorPane.add(editor);
transferHandler = new XFormsWizardTransferHandler(editor);
editor.setTransferHandler(transferHandler);
XFormsWizardTreeCellRenderer cr = new XFormsWizardTreeCellRenderer();
boTree.setCellRenderer(cr);
boTree.setDragEnabled(true);
boTree.setTransferHandler(transferHandler);
DefaultTreeSelectionModel selModel = new DefaultTreeSelectionModel();
selModel.setSelectionMode(DefaultTreeSelectionModel.SINGLE_TREE_SELECTION);
boTree.setSelectionModel(selModel);
actionTree.setCellRenderer(cr);
actionTree.setDragEnabled(true);
actionTree.setTransferHandler(transferHandler);
actionTree.setRootVisible(false);
}
示例5: CTagsTree
import javax.swing.tree.DefaultTreeSelectionModel; //导入方法依赖的package包/类
/**
* Creates a new tree object.
*
* @param parent Parent window used for dialogs.
* @param graph Graph shown in the window.
* @param manager Provides tag information.
*/
public CTagsTree(final JFrame parent, final ZyGraph graph, final ITagManager manager) {
m_parent = Preconditions.checkNotNull(parent, "IE02308: Perent argument can not be null");
m_graph = Preconditions.checkNotNull(graph, "IE01776: Graph can not be null");
m_tagManager = Preconditions.checkNotNull(manager, "IE01777: Manager argument can not be null");
m_model = new CTagsTreeModel(this);
setModel(m_model);
getModel().addTreeModelListener(new InternalModelListener());
addMouseListener(m_mouseListener);
m_graph.addListener(m_graphSelectionListener);
m_graph.addListener(m_graphVisibilityListener);
setRootVisible(false);
m_rootNode = new CRootTagTreeNode(parent, this, graph, m_tagManager);
m_model.setRoot(m_rootNode);
setCellRenderer(new CTagTreeCellRenderer()); // ATTENTION: UNDER NO CIRCUMSTANCES MOVE THIS LINE
// ABOVE THE SETROOT LINE
m_model.nodeStructureChanged(m_rootNode);
final List<IDropHandler> handlers = new ArrayList<IDropHandler>();
handlers.add(new CTagSortingHandler());
new CDefaultTransferHandler(this, DnDConstants.ACTION_COPY_OR_MOVE, handlers);
final DefaultTreeSelectionModel selectionModel = new DefaultTreeSelectionModel();
selectionModel.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
setSelectionModel(selectionModel);
final InputMap windowImap = getInputMap(JComponent.WHEN_FOCUSED);
windowImap.put(HotKeys.DELETE_HK.getKeyStroke(), "DELETE");
getActionMap().put("DELETE", CActionProxy.proxy(new DeleteAction()));
}
示例6: TypesTree
import javax.swing.tree.DefaultTreeSelectionModel; //导入方法依赖的package包/类
public TypesTree() {
setRootVisible(false);
setDragEnabled(true);
setDropMode(DropMode.INSERT); // Dropped objects are inserted behind the drop location.
setToggleClickCount(1); // Child nodes expand with a single click.
final DefaultTreeSelectionModel selectionModel = new DefaultTreeSelectionModel();
selectionModel.setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
setSelectionModel(selectionModel);
final IconNodeRenderer renderer = new IconNodeRenderer();
renderer.setFont(GuiHelper.MONOSPACED_FONT);
setCellRenderer(renderer);
}
示例7: AttributePanel
import javax.swing.tree.DefaultTreeSelectionModel; //导入方法依赖的package包/类
public AttributePanel(Provider prv, int visibleRows) {
provider = prv;
try {
attributes = provider.getAttributes();
} catch (Exception pe) {
pe.printStackTrace();
}
setLayout(new GridLayout(1, 1));
// Init tree node and model (attribute tree nodes)
root = new AttributeRootNode();
model = new DefaultTreeModel(root);
// Init tree view
tree = new JTree(model);
if (visibleRows != 0)
tree.setVisibleRowCount(visibleRows);
tree.putClientProperty("JTree.lineStyle", "Angled");
tree.setRootVisible(false);
tree.setShowsRootHandles(true);
smodel = new DefaultTreeSelectionModel();
smodel
.setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
smodel
.addTreeSelectionListener(slistener = new AttributeSelectionListener());
tree.setSelectionModel(smodel);
tree.setCellRenderer(new AttributeCellRenderer());
tree.addMouseListener(new AttributePopup());
scrollPane = new JScrollPane(tree);
scrollPane.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
add(scrollPane, BorderLayout.CENTER);
// validate components
tree.validate();
scrollPane.validate();
}