本文整理了Java中javax.swing.JTree.addTreeSelectionListener()
方法的一些代码示例,展示了JTree.addTreeSelectionListener()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTree.addTreeSelectionListener()
方法的具体详情如下:
包路径:javax.swing.JTree
类名称:JTree
方法名:addTreeSelectionListener
暂无
代码示例来源:origin: SonarSource/sonarqube
treeScrollPane.setViewportView(componentTree);
componentTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
componentTree.addTreeSelectionListener(new TreeSelectionListener() {
@Override
public void valueChanged(TreeSelectionEvent e) {
代码示例来源:origin: pmd/pmd
private void init() {
model.addViewerModelListener(this);
setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), NLS.nls("AST.PANEL.TITLE")));
setLayout(new BorderLayout());
tree = new JTree((TreeNode) null);
tree.addTreeSelectionListener(this);
tree.addMouseListener(new MouseAdapter() {
@Override
public void mouseReleased(MouseEvent e) {
if (e.isPopupTrigger()) {
TreePath path = tree.getClosestPathForLocation(e.getX(), e.getY());
tree.setSelectionPath(path);
JPopupMenu menu = new ASTNodePopupMenu(model, (Node) path.getLastPathComponent());
menu.show(tree, e.getX(), e.getY());
}
}
});
add(new JScrollPane(tree), BorderLayout.CENTER);
}
代码示例来源:origin: stackoverflow.com
tree.getSelectionModel().setSelectionMode
(TreeSelectionModel.SINGLE_TREE_SELECTION);
tree.addTreeSelectionListener( new TreeSelectionListener() {
public void valueChanged(TreeSelectionEvent tse) {
if (sortable) {
代码示例来源:origin: pentaho/mondrian
/**
* Constructor
*
* @param tree The tree to track
*/
public JTreeUpdater(JTree tree) {
this.tree = tree;
this.tree.addTreeExpansionListener(this);
this.tree.addTreeSelectionListener(this);
}
代码示例来源:origin: apache/pdfbox
private void init()
{
panel = new JPanel(new BorderLayout());
statusField = new JTextField();
statusField.setEditable(false);
panel.add(statusField);
defaultBorder = new BevelBorder(BevelBorder.LOWERED);
errorBorder = new BevelBorder(BevelBorder.LOWERED, Color.RED, Color.RED);
statusField.setAction(textInputAction);
tree.addTreeSelectionListener(this);
}
代码示例来源: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: ron190/jsql-injection
/**
* Build editor, add tree and mouse listener.
*/
public CellEditorNode() {
this.defaultTreeRenderer = new CellRendererNode();
MediatorGui.treeDatabase().addTreeSelectionListener(this);
MediatorGui.treeDatabase().addMouseListener(this);
}
代码示例来源: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: jshiell/checkstyle-idea
resultsTree.addTreeSelectionListener(treeSelectionListener);
final MouseListener treeMouseListener = new ToolWindowMouseListener();
resultsTree.addMouseListener(treeMouseListener);
代码示例来源:origin: org.apache.uima/uimaj-tools
/**
* Adds the tree selection listener.
*
* @param sel the sel
*/
// add a tree selection listener to the JTree
public void addTreeSelectionListener(TreeSelectionListener sel) {
tree.addTreeSelectionListener(sel);
}
代码示例来源:origin: org.icepdf.os/icepdf-viewer
/**
* Called by SwingViewerBuilder, so that SwingController can setup event handling
*/
public void setOutlineComponents(JTree tree, JScrollPane scroll) {
outlinesTree = tree;
outlinesScrollPane = scroll;
outlinesTree.addTreeSelectionListener(this);
}
代码示例来源:origin: pentaho/mondrian
tree.setModel(model);
tree.setCellRenderer(renderer);
tree.addTreeSelectionListener(this);
代码示例来源:origin: stackoverflow.com
public class Frame1 extends JFrame implements JTreeSelectionListener {
private JTree jtree = new JTree();
public Frame1() {
jtree.addTreeSelectionListener(this);
}
public void valueChanged(TreeSelectionEvent e) {
// can now access jtree directly ...
}
}
代码示例来源:origin: guru.nidi/jdepend
/**
* Registers the specified listener with this tree.
*
* @param l Tree selection listener.
*/
public void addTreeSelectionListener(TreeSelectionListener l) {
getTree().addTreeSelectionListener(l);
}
代码示例来源:origin: igniterealtime/Spark
private void addListeners() {
historyTree.addTreeSelectionListener(onTreeSelected());
btnClose.addActionListener(onCloseBtnClick());
btnFind.addActionListener(onFindBtnClick());
}
代码示例来源:origin: org.junit/com.springsource.junit
public TestHierarchyRunView(TestRunContext context) {
fTestContext= context;
fTreeBrowser= new TestSuitePanel();
fTreeBrowser.getTree().addTreeSelectionListener(
new TreeSelectionListener() {
public void valueChanged(TreeSelectionEvent e) {
testSelected();
}
}
);
}
代码示例来源:origin: fr.ifremer/isis-fish
protected void createFisheryRegionTree() {
$objectMap.put("fisheryRegionTree", fisheryRegionTree = new JTree());
fisheryRegionTree.setName("fisheryRegionTree");
fisheryRegionTree.setRootVisible(true);
fisheryRegionTree.setSelectionRow(0);
fisheryRegionTree.addTreeSelectionListener(JAXXUtil.getEventListener(TreeSelectionListener.class, "valueChanged", this, "doValueChanged__on__fisheryRegionTree"));
}
代码示例来源:origin: com.google.code.findbugs/findbugs
void setupTreeListeners() {
// noinspection ConstantIfStatement
if (false) {
tree.addTreeExpansionListener(new MyTreeExpansionListener());
}
tree.addTreeSelectionListener(new MyTreeSelectionListener());
tree.addMouseListener(new TreeMouseListener());
}
代码示例来源:origin: fr.ifremer/isis-fish
protected void createFisheryRegionTree() {
$objectMap.put("fisheryRegionTree", fisheryRegionTree = new JTree());
fisheryRegionTree.setName("fisheryRegionTree");
fisheryRegionTree.setRootVisible(true);
fisheryRegionTree.setRowHeight(0);
fisheryRegionTree.setSelectionRow(0);
fisheryRegionTree.addTreeSelectionListener(JAXXUtil.getEventListener(TreeSelectionListener.class, "valueChanged", this, "doValueChanged__on__fisheryRegionTree"));
}
内容来源于网络,如有侵权,请联系作者删除!