How to disable tree node selection

  • Permalink
  • submit to reddit
  • Email
  • Follow


Is there an API to temporarily diable node selection in a JTree?  What I
want is to keep the currently selected node to stay selected and disallow
selecting any other tree nodes.  I would like to be able to switch this
feature on and off programmatically.

Thanks
Bora


0
Reply Bora 6/29/2004 3:42:33 PM

See related articles to this posting


you should write your own TreeSelectionModel (better extend
DefaultTreeSelectionModel).
1) Introduce boolean variable - for example:
    boolean freezed;

2) add getter and setter for freezed;

3) override appropriate methods - for example:

public void setSelectionPath(TreePath path) {
    if(freezed) {
        return;
    }
    else {
        super.setSelectionPath(path);
    }
}

-- 
Andrei Kouznetsov
http://uio.dev.java.net Unified I/O for Java
http://reader.imagero.com Java image reader


0
Reply ak 6/29/2004 3:58:09 PM
comp.lang.java.gui 8295 articles. 15 followers. Post

1 Replies
887 Views

Similar Articles

[PageSpeed] 45


  • Permalink
  • submit to reddit
  • Email
  • Follow


Reply:

Similar Artilces:

programatically select a tree node
How do I programaticlly select a tree node in my JTree after it's just been created and added to my tree. I'm trying to select it (I'm guessing this means highlighted and selected as if the user just clicked on it) by the following, but this isn't working. [code] // create new node and add to tree DefaultMutableTreeNode myNode = addNode(getMyRoot(), myInfo, true); // get the path from the root to the node Object[] objPath = myNode.getUserObjectPath(); // and convert it to a Treepath, then select it. TreePath tPath = new TreePath(objPath); g...

Selecting a tree node in JTree
Hello! I am using the following code to select a node in JTree, given the node object itself: ******************************************* JTree xmlTree = new JTree(); //Building up the tree... //Selecting a node: TreeNode[] pathNodes = node.getPath(); TreePath path = new TreePath(pathNodes); xmlTree.setSelectionPath(path); ******************************************* But the node is not selected. TreePath seems to be ok. I am trying to do it right as I select a node on another JTree component!!! Does that matter??? Is focus issues relevant here? Thanks !!! ok, ok , I found the reason ...

Select disabled item in tree
I'm using a tree to configure different stages in an experiment. Whenever I click on a branch of the tree, using an event structure (on Tree: Value change), I get the current settings of that branch which I can then edit. I want the user to be able to select a branch in the tree and enable or disable that element. I can disable a branch with property nodes with no problem, but once the branch is disabled, I am no longer able to select it and thus I can't enable it again since I can never run the event structure with that branch as the selected branch. Is there a way around this? Thank...

how to click a button, a node in a tree is selected
Hello all I have a MenuTreeNavigator in a MainWindow that allows users to select different nodes as the following: ---------------------------------------------------------------------------- ---------------------------- public class MenuTreeNavigator implements TreeSelectionListener, TreeExpansionListener { ...... public MenuTreeNavigator(MainWindow mainWindow) { this.mainWindow = mainWindow; ......... public void valueChanged(TreeSelectionEvent treeSelectionEvent) { Object selectedNode = treeSelectionEvent.getPath().getLastPathComponent(); if (selectedNode.getClass().getName().equa...

keeping multiple highlighted tree nodes selected
DISCONTIGUOUS_TREE_SELECTION allows me to select and highlight multiple JTree nodes. I then right click on the highlighted selections to bring up a popup menu which will affect the configuration of those nodes, but the problem is when I make that initial right click on the highlighted nodes, all the selections go away and I'm left w/ a single selected tree node. Any ideas how to keep the selection count up when right clicking on any one of the multiple highlighted nodes and not have them dissappear except for the one I right click on? On 26 Sep, 20:04, "William Z." <Wizumw....

tree control: How to disable the selection of a child item
Hello everyone, Im having trouble with disabling the selection of a child item in a tree control. I dont know if its possible but havent found any answers on this forum regarding this issue.Example:Parent tag 1&nbsp;&nbsp;&nbsp; child item 1&nbsp;&nbsp;&nbsp; child item 2Parent tag 2&nbsp;&nbsp;&nbsp; child item a&nbsp;&nbsp;&nbsp; child item b--------------------------------------------------------What i would like to do is being able to select the parent tags but not the child items, because i use the name of the selected item in my program to ...

selecting nodes between other nodes
Hi! <root> <foo>bar</foor> <blah /> <blah2 /> <a> <b /> <c /> </> </root> I want to select everything between <foo> and <a>. Is this possible? Timo In article <2jbjjhFvf4ttU1@uni-berlin.de>, Timo Nentwig <tcn@spamgourmet.org> wrote: % <root> % <foo>bar</foor> % <blah /> % <blah2 /> % <a> % <b /> % <c /> % </> % </root> % I want to select everything between <foo> and <a>. Is this possible? How about <xsl:styles...

find path from one tree node to another tree node
Hello,I have a non binary tree and looking for a solution to find the pathbetween two given nodes (not just leaves).Is there a class in the Java class library that provides thefunctionality already? If not, can someonerecommend a library. A description of the algorithm would also help.Thanks,Peter Peter Mueller <peter.o.mueller@gmx.de> writes:>I have a non binary tree and looking for a solution to find the path>between two given �������� Sometimes, there are /several/ paths between two points. But you surely can go up to the root and then...

select nodes with child node A and child node B
I have an XML document that has multiple childe nodes like the one at the end of this message What syntax would I use with selectNodes to select all viewentry nodes that have an entrydata child node with a name attribute equal to "CourseOrMeetingName" that has a text childe node with the text Course ABC AND that also have an entrydata child with a name attribute equal to Start Date that has a datetime child node with the text 20070110 I was trying something like //viewentry[ (entrydata[@name='CourseOrMeetingName'][text='Course ABC']) and (entrydata[@name='St...

Selecting Nodes Using Subtotal of Child Nodes
I'm having difficulty finding the correct syntax that will allow me to select a group of invoices based on the total of an amount column located in its line items. Below are simplified examples of my XML and XSLT files: XML FILE <?xml version="1.0" standalone="yes"?> <?xml-stylesheet type="text/xsl" href="OutstandingInvoiceBalances.xslt"?> <ProgramData> <Invoices> <InvoiceID>1</InvoiceID> <InvoiceNumber>100</InvoiceNumber> <Amount>1000.00</Amount> </Invoices> <I...

tree node parent, trees as data structure
Hi, I need to use a tree structure to represent data divided in groups and I'm thinking about representing it with a binary tree: left child - sibling right child - child that's good for traversing, etc. My doubt arises when I need to reference the parent of a node. The only way I can think of is adding a field to each node pointing to the parent Any other suggestions? Would you use a binary tree or stick with a general tree? Or maybe another data structure like a list of lists? Enrico you can use a stack of the nodes currently visited "DoctorC" <ecolautti@poc...

Nodes Selected property fails to visually select
I set a Node's selected property to True and also set the Ensure Visible property to True , yet, when I see the Node in the TreeView the Node is not visually selected, i.e. there is no focus rectangle around it nor is its background highlighted as it would if I manually clicked the Node. Why is this? How can I force the Node to be visually selected as well when I set the .Selected property to True? I set the .Selected property like so: Me.trv.Nodes.Item(Me.cmdFields(iIndex%).Tag).Selected = True Me.trv.Nodes.Item(Me.cmdFields(iIndex%).Tag).EnsureVisible A check of the debugger sh...

Select Node Using position or value of another node.
Hi, I'm trying to get the value of another node using the position of another node or the name of the tag. Such that the current node is one of the contacts child nodes sec or prim and doing <xsl:value-of select="//cust[seq = position()]/name"/> Should return jon for the prim tag and peter for the sec tag, but fails as position() appears to resolve to the position of cust not the contacts node alternatively I would like to do something like <xsl:value-of select="//cust[seq = [name()='prim' then 0 else 1]]/name"/> <custs> ...

XSL select only nodes which contain a specific child node
Given the following extremely simplified XML... <AA> <BB></BB> <BB><CC>foo</CC></BB> <BB></BB> <BB><CC>bar</CC></BB> </AA> ....is there an easy way to use and XSL select to get only the <BB> nodes which have a <CC> child node? <xsl:for-each select="AA/BB"> Gives me 4 nodes: <BB></BB> <BB><CC>foo</CC></BB> <BB></BB> <BB><CC>bar</CC></BB> <xsl:for-each select="AA/BB/CC"> Give...

I want to select all the node names beneath a given node
Dear all I have a diffgram: <?xml version="1.0" standalone="yes"?> <diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1"> <NewDataSet> <PolicyInwards diffgr:id="PolicyInwards1" msdata:rowOrder="0" diffgr:hasChanges="modified"> <PolicyID>POL0001</PolicyID> <InsuredName>Insured Co 111</InsuredName> <InceptDate>2007-01-01T00:00:00+00:00</InceptDate> <BrokerCode>...

TREEVIEW: How to display all parent nodes for opened and selected node?
When use TreeView I want to display entire "path" of opened node. To be precise - when node is selected and/or opened, is it possible (and how) to get all other parent nodes of that selected/opened node? I tried everything but can't get to solution... :( Arminio /Temp from Google/ arminio_grgic@yahoo.com wrote: > When use TreeView I want to display entire "path" of opened node. To be > precise - when node is selected and/or opened, is it possible (and how) > to get all other parent nodes of that selected/opened node? Given a node, you ca...

builder.node('select'..) selected not working solution
FYI, with something like this: hotelement = "hotelement"+hotcount; hotspot = Builder.node('div', { id:'hotspot'+hotcount, className:'hotspot', style:''+divstyle }, [ Builder.node('select', {id:hotelement, onChange:hotspotlink}, [ Builder.node('option',{value:'textfield', selected:''},"textfield"), Builder.node('option',{value:'textarea'},"textarea"), Builder.node('option',{value:'dropdown'},"dropdown"), Builder.node('...

I want to select all the node names beneath a given node #2
Dear all I have a diffgram: <?xml version="1.0" standalone="yes"?> <diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1"> <NewDataSet> <PolicyInwards diffgr:id="PolicyInwards1" msdata:rowOrder="0" diffgr:hasChanges="modified"> <PolicyID>POL0001</PolicyID> <InsuredName>Insured Co 111</InsuredName> <InceptDate>2007-01-01T00:00:00+00:00</InceptDate> <BrokerCode&g...

[MSW] Wrong selection events in multi selection tree control
Hello, I've been experiencing a number of issues with wxTreeCtrl with wxTR_MULTIPLE style. I've outlined these issues in http://trac.wxwidgets.org/ticket/626#comment:13 and i've attached a patch against wxWidgets SVN trunk to fix it. Seems this ticket has been open for around 6 years. I'm fairly new to wxWidgets development and only been using wxWidgets since last December so i'm not completely familiar with the processes for patching. Would I need to backport this patch to wxWidgets 2.8 SVN as well? Regards, Jonathan ...

Definition of a leaf node of red-black trees and binary search trees ...
Can someone please help clarify? Wikipedia article on Red-Black trees (http://en.wikipedia.org/wiki/Red- black_tree) defines: The leaf nodes of red-black trees do not contain data. My understanding of leaf node of a binary search tree on the other hand, is that it is a node with no children. Wikipedia article (http:// en.wikipedia.org/wiki/Binary_search_tree) seems to confirm it. Does it mean that the leaf node of a red-black tree is defined differently from that of a binary search tree? On May 11, 11:23=A0am, Kedar Mhaswade <kedar.mhasw...@gmail.com> wrote: > Can someone please h...

XSL HOWDOI use attribute of current node to select a different node?
I know I can select a node by attribute value using something like <xsl:apply-templates select="//*[@Name='Joe']"/> How can I replace Joe with an attribute from the current node? I.e., the current node has an attribute Manager="Fred". I want a select expression something like "//*[@Name='"<xsl:value-of select="@Manager"/>"']" This gives me the text I want, but I can't figure out how to embed it into the xsl:apply-templates' select. I.e., the following won't work; <xsl:apply-template...

Hi, I want to implement a General Tree Data structure (Not Binary Tree ) which have more than 2 sub nodes?
Hello Friends I have a problem in Data Structure (In C) i want to implement a General tree having three child nodes of each parent node ...please send me any simple Example( code) by which i can understand General Tree codes.....node be int value if possible than help me for a name(string) sharan said: > Hello Friends I have a problem in Data Structure (In C) i want to > implement a General tree having three child nodes of each parent > node ...please send me any simple Example( code) by which i can > understand General Tree codes.....node be int value if possible than > help...

XSLT Select nodes without text-node children whose names starts with specifix text
Question on XSL expression Got this XML: <Body> <Page> <Line no="9" detail="true"> <onefield>onefieldstext</onefield> <twofield>twofieldstext</twofield> </Line> <Line no="10" detail="true"> <onefield>onefieldstext</onefield> <fgman9>fgmanfieldstext</fgman9> <twofield>twofieldstext</twofield> </Line> <Line no="11" detail="true"> <onefield>onefieldstext</onefield> <twofield>twofieldste...

i dont find chart getting disabled even after disabling it via it's property node
Hi All , &nbsp; &nbsp;&nbsp;&nbsp; I am trying to disable a chart in my vi but when the vi runs,it is showing it disabled &amp; grayed but the data is still traversing thorugh it as the timing on chart is increrasing continously.I am using a case structure and within that ,in one casse ,it is disabled &amp; grayed and no data should traverse through it and in second case ,it is enabled and data should traverse through it.I am using 4 such case structures.I am getting the result properly in 3 case structures but not in one case .Please suggest me how can I fix this probl...