本文整理了Java中javax.swing.JTree.getSelectionModel()
方法的一些代码示例,展示了JTree.getSelectionModel()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTree.getSelectionModel()
方法的具体详情如下:
包路径:javax.swing.JTree
类名称:JTree
方法名:getSelectionModel
暂无
代码示例来源:origin: skylot/jadx
treeModel = new DefaultTreeModel(treeRootNode);
tree = new JTree(treeModel);
tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
tree.addMouseListener(new MouseAdapter() {
@Override
代码示例来源:origin: SonarSource/sonarqube
componentTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
componentTree.addTreeSelectionListener(new TreeSelectionListener() {
@Override
代码示例来源:origin: runelite/runelite
widgetTree.setRootVisible(false);
widgetTree.setShowsRootHandles(true);
widgetTree.getSelectionModel().addTreeSelectionListener(e ->
代码示例来源:origin: deathmarine/Luyten
tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
tree.setCellRenderer(new CellRenderer());
TreeListener tl = new TreeListener();
代码示例来源:origin: stackoverflow.com
tree.setDropMode(DropMode.ON_OR_INSERT);
tree.setTransferHandler(new TreeTransferHandler());
tree.getSelectionModel().setSelectionMode(
TreeSelectionModel.CONTIGUOUS_TREE_SELECTION);
expandTree(tree);
代码示例来源:origin: stackoverflow.com
tree.getSelectionModel().setSelectionMode
(TreeSelectionModel.SINGLE_TREE_SELECTION);
tree.addTreeSelectionListener( new TreeSelectionListener() {
代码示例来源:origin: pentaho/mondrian
public void valueChanged(TreeSelectionEvent treeSelectionEvent) {
if (this.tree.getSelectionPaths() != null
&& this.tree.getSelectionPaths().length > 0)
{
selectedTreePaths =
this.tree.getSelectionModel().getSelectionPaths();
}
}
}
代码示例来源:origin: geotools/geotools
processList.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
processList
.getSelectionModel()
.addTreeSelectionListener(
new TreeSelectionListener() {
代码示例来源:origin: knowm/XChart
/** Constructor */
public XChartDemo() {
super(new GridLayout(1, 0));
// Create the nodes.
DefaultMutableTreeNode top = new DefaultMutableTreeNode("XChart Example Charts");
createNodes(top);
// Create a tree that allows one selection at a time.
tree = new JTree(top);
tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
// 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 Chart Panel
chartPanel = new XChartPanel(new AreaChart01().getChart());
// Add the scroll panes to a split pane.
splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
splitPane.setTopComponent(treeView);
splitPane.setBottomComponent(chartPanel);
Dimension minimumSize = new Dimension(130, 160);
treeView.setMinimumSize(minimumSize);
splitPane.setPreferredSize(new Dimension(700, 700));
// Add the split pane to this panel.
add(splitPane);
}
代码示例来源:origin: knowm/XChart
protected void init() {
// Create the nodes.
DefaultMutableTreeNode top = new DefaultMutableTreeNode("XChart Example Charts");
createNodes(top);
tree = new JTree(top);
// Create a tree that allows one selection at a time.
tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
// 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 Chart Panel
tabbedPane = new JTabbedPane();
for (int i = 0; i < tree.getRowCount(); i++) {
tree.expandRow(i);
}
// select first leaf
DefaultMutableTreeNode firstLeaf = top.getFirstLeaf();
tree.setSelectionPath(new TreePath(firstLeaf.getPath()));
// Add the scroll panes to a split pane.
splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
splitPane.setTopComponent(treeView);
splitPane.setBottomComponent(tabbedPane);
Dimension minimumSize = new Dimension(130, 160);
treeView.setMinimumSize(minimumSize);
splitPane.setPreferredSize(new Dimension(700, 700));
// Add the split pane to this panel.
add(splitPane);
}
代码示例来源:origin: pentaho/mondrian
/**
* Call this method whenever you update the tree and needs it reloaded
*/
public synchronized void update() {
synchronized (this.tree) {
this.tree.removeTreeExpansionListener(this);
this.tree.removeTreeSelectionListener(this);
((DefaultTreeModel) this.tree.getModel()).reload();
for (TreePath treePath : expandedTreePaths) {
this.tree.expandPath(treePath);
}
this.tree.getSelectionModel().setSelectionPaths(selectedTreePaths);
this.tree.addTreeExpansionListener(this);
this.tree.addTreeSelectionListener(this);
}
}
代码示例来源:origin: stackoverflow.com
m_tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
m_tree.setShowsRootHandles(true);
m_tree.setEditable(false);
代码示例来源:origin: ron190/jsql-injection
this.tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
代码示例来源:origin: pentaho/mondrian
tree.getSelectionModel().setSelectionMode(
DefaultTreeSelectionModel.SINGLE_TREE_SELECTION);
代码示例来源:origin: org.netbeans.api/org-openide-explorer
/** Constructor.
*/
public ContextTreeView() {
tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
}
代码示例来源:origin: org.netbeans.api/org-openide-explorer
/** Returns the current selection mode, one of
* <code>TreeSelectionModel.SINGLE_TREE_SELECTION</code>,
* <code>TreeSelectionModel.CONTIGUOUS_TREE_SELECTION</code> or
* <code>TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION</code>.
* @since 2.15
* @return selection mode
*/
public int getSelectionMode() {
return tree.getSelectionModel().getSelectionMode();
}
代码示例来源:origin: otros-systems/otroslogviewer
@Override
public void actionPerformed(ActionEvent e) {
TreePath[] selectedPaths = tree.getSelectionModel().getSelectionPaths();
for (TreePath treePath : selectedPaths) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) treePath.getLastPathComponent();
Clazz userObject = (Clazz) node.getUserObject();
list.add(userObject.toFullString());
}
ClassLikeFilter.this.mode = mode;
listener.ifPresent(LogFilterValueChangeListener::valueChanged);
}
代码示例来源:origin: otros-systems/otroslogviewer
@Override
public void actionPerformed(ActionEvent e) {
TreePath[] selectedPaths = tree.getSelectionModel().getSelectionPaths();
for (TreePath treePath : selectedPaths) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) treePath.getLastPathComponent();
Clazz userObject = (Clazz) node.getUserObject();
list.remove(userObject.toFullString());
}
listener.ifPresent(LogFilterValueChangeListener::valueChanged);
}
代码示例来源:origin: org.netbeans.api/org-openide-explorer
/** Deinitializes listeners.
*/
@Override
public void removeNotify() {
super.removeNotify();
tree.getSelectionModel().removeTreeSelectionListener(managerListener);
}
代码示例来源:origin: org.netbeans.api/org-openide-explorer
protected void showSelection(TreePath[] treePaths) {
tree.getSelectionModel().setSelectionPaths(treePaths);
if (treePaths.length == 1) {
showPathWithoutExpansion(treePaths[0]);
}
}
内容来源于网络,如有侵权,请联系作者删除!