Extreme JTree.expandPath frustration

I've read through about 80 posts on this subject and cannot solve my problem. I am trying to dynamically select a node in a JTree. I'm using a custom TreeModel to model an XML file. I select the node with the following code:
jTree.setExpandsSelectedPaths(true);
jTree.setSelectionPath(treePath);
jTree.expandPath(treePath);
jTree.scrollPathToVisible(treePath);I know the node is being selected b/c a subsequent action is taken via the tree listener, and a call to jTree.getSelectionPath() shows the expected treePath. The problem is that graphically the treePath is niether expanded nor highlighted.
If I call jTree.getRowForPath(jTree.getSelectionPath())
-or- jTree.getRowForPath(treePath) I get "-1" which according to the Javadocs can only happen "if any of the elements in path are hidden under a collapsed parent". But I've eliminated this possibility by expanding the entire tree.
Can anyone please help.
Thanks,
bb

My problem turned out to be a problem in a custom equals method. A cruel bug elsewhere in the code was fooling me into thinking the listener was triggering correctly.
I'm not sure I understand your question but this might help. The TreePath[] needs to include the Node objects that comprise the path you want to select. In my case I have no reference to the actual Nodes so I have to create a new TreePath[] that has identical nodes (but not the actual nodes). The actual nodes and the identical nodes do contain a reference to the same encapsulated object. I can therefore walk the tree row-by-row and compare the object encapsulated by the actual Node to the object encapsulated by the identical node. When a match is found I expand that row and continue the search until I reach the end of the TreePath[]. Here is roughly what the code might look like:
"path" is the identical TreePath, "getElement()" returns a reference to the encapsulated object.static void selectNode(TreePath path) {
     TreePath select = path;
     TreePath rowPath = null;
     int row = 0;
     int i = 1;                    // ignore the root
     Element element1, element2;          
     while (row < tree.getRowCount()) {
          while (i < select.getPathCount()) {
               rowPath = tree.getPathForRow(row);
               if(i >= rowPath.getPathCount()) i = rowPath.getPathCount()-1;
               element1 = ((AdapterNode)(rowPath.getPathComponent(i))).getElement();
               element2 = ((AdapterNode)(select.getPathComponent(i))).getElement();
               if(element1.equals(element2)) {
                    if(i == select.getPathCount() - 1) break;
                    tree.expandRow(row); 
                    i++;
               row++;
          break;
     tree.setSelectionRow(row);
     tree.scrollRowToVisible(row);
}

Similar Messages

  • Problem, errors in JTree.expandPath(TreePath)

    I got errors when doing JTree.expandPath(TreePath), and I have no idea, whats wrong with my code, I printed out the TreePath, and it looks alright, I just dont know why it doesnt work.

    Now, if only this answer wasn't three years late, i'm sure you'd be getting all the dukes you deserve. Seriously, why resurrect a three year old thread with a potentially incorrect answer?

  • Please help me..JTRee expandPath().. thanks...please help!!!

    Hi all . THis is how I built my Jtree:'
    public class AECategory
    public String name;
    public String description;
    public String value;
    public AECategory(String name, String description, String value)
    this.name = name;
    this.description = description;
    this.value = value;
    public String toString() {return name;}
    public String getName() {    return name;}
    public String getDescription() {return description;}
    public String getValue() {    return value;}
    public void setName(String name) {this.name=name;}
    public void setDescription(String desc) {this.description=desc;}
    public void setValue(String val) {this.value=val;}
    public TreeModel buildCategoryTree(AECategory[] categories)
    System.out.println("Building a Tree Model now");
    System.out.println("Using "+categories.length+" categories");
    // Create an array of nodes
    DefaultMutableTreeNode[] nodes = new DefaultMutableTreeNode[categories.length];
    // Loop through all categories and create a node for every category
    for(int i=0;i<categories.length;i++)
    nodes[i] = new DefaultMutableTreeNode(categories); // Creates a node for this category
    System.out.println("nodes i :"+nodes[i]);
    // Now all nodes should be created, so we can start building the actual tree
    DefaultMutableTreeNode root = null;
    for(int i=0;i<categories.length;i++)
    String thisValue = categories[i].getValue(); // The current category value
    System.out.println("thisvalue :"+thisValue);
    String parentValue = ""; // The parents category value
    if(thisValue.indexOf('-')>0)
    parentValue = thisValue.substring(0, thisValue.lastIndexOf('-'));
    } else {
    root = nodes[i]; // We found the root element because there are no dashes in the value
    for(int loop=0;loop<categories.length;loop++)
    if(categories[loop].getValue().equals(parentValue))
    nodes[loop].add(nodes[i]); // Add this node to it's parent
    System.out.println("root:"+root);
    DefaultTreeModel treeModel = new DefaultTreeModel(root);
    return treeModel;
    and I have a JList, all I wanted is every time I double clicked at each item of the list, I want to following treepath to expand, but I didn't work for me.
    Here is my codes:
    lstOtherCategories.addListSelectionListener(new ListSelectionListener(){
    public void valueChanged(ListSelectionEvent le){
    if( (le.getValueIsAdjusting() == false) || (le.getFirstIndex()==-1) )
    return;
    Object[] path = new Object[2];
    DefaultMutableTreeNode alerts = new DefaultMutableTreeNode("Alerts");
    DefaultMutableTreeNode notes = new DefaultMutableTreeNode("Notes");
    path[0] = alerts; //replace myRootObject with your root object
    path[1] =notes;
    TreePath tp = new TreePath(path);
    System.out.println("tree path :" +tp);
    jtreeCategoryTree.expandPath(tp);
    }// end of public void valueChanged
    It compiled okey but It didn't do anything when I run..
    Please show me what I am doing wrong here. thanks a million

    Please help me!! does anyone knows about this.? please help

  • Extremely Disappointed and Frustrated with ZFS

    I feel like crying. In the last 2 years of my life ZFS has caused me more professional pain and grief than anything else. At the moment I'm anxiously waiting for a resilver to complete, I expect that my pool will probably fault and I'll have to rebuild it.
    I work at a small business, and I have two Solaris 11 servers which function as SAN systems primarly serving virtual machine disk images to Proxmox VE cluster. Each is fitted with an Areca 12 port SATA controller put in JBOD mode, and populated with WD Caviar Black 2TB drives (probably my first and biggest mistake, was in not using enterprise class drives). One system is configured as a ZFS triple mirror, and the other a double mirror, both have 3 hot spares.
    About a year ago I got CKSUM errors on one of the arrays I promptly ran zpool scrub on the array, and stupidly I decided to scrub the other array at the same time. The scrub quickly turned into resilvers on both arrays as more CKSUM errors were uncovered, and as the resilver continued the CKSUM count rose until both arrays faulted and were irrecoverable. Irrecoverable metadata corruption was the error I got from ZFS. After 20+ hours of attempted recovery, trying to play back the ZIL I had to destroy them both and rebuild everything. I never knew for certain what the cause was, but I suspected disk write caching on the controller, and/or the use of a non-enterprise class flash drive for ZIL.
    In the aftermath did extremely thorough checking of all devices. I checked each backplane port, each drive for bad sectors, SATA controller onboard RAM, main memory, ran extended burn-in testing, etc. I then rebuilt the arrays without controller write caching and no seperate ZIL device. I also scheduled weekly scrubbing, and scripted ZFS alerting.
    Yesterday I got an alert from the controller on my array with the triple mirror about read errors on one of the ports. I ran a scrub which completed and then I proceeded to replace the drive I was getting read errors on. I offlined the old drive and inserted a brand new drive and ran zfs replace. Re-silver started fast and then the rate quickly dropped down to 1.0MB/s, my controller began spitting out a multitude of SATA command timeout errors on the port of the newly inserted drive. Since the whole array had essential froze up, I popped the drive out and everything ran back at full speed, resilvering against one of the hot spares. Now the resilver soon started uncovering CKSUM errors similar to the disaster I had last year. Error counts rose and now my system dropped another drive off in the same mirror set and is resilvering 2 drives in the same set, with the third drive in the set showing 6 CKSUM errors. I'm afraid I'm going to lose the whole array again, as the only drive left in the set is showing errors as well. WTF?!?!?!?!?!?!
    So I suspect I have a bad batch of disks, however, why the heck did zfs scrub complete and show no errors? What is the point of ZFS scrub if it doesn't accuratly uncover errors? I'm so frustrated that these types of errors seem to show up only during resilvers. I'm beginning to think ZFS isn't as robust as advertised....

    FMA does notify admins automatically through the smtp-notify service via mail notification to root. You
    can customize this service to send notification to your own email account on any system.
    The poster said he has scripted for ZFS, but I don't know if that means reviewing zpool status or
    FMA data.
    With ongoing hardware problems, you need to review FMA data as well. See the example below.
    Rob Johnston has a good explanation of this smtp-notify service, here:
    https://blogs.oracle.com/robj/entry/fma_and_email_notifications
    For the system below, I had to enable sendmail to see the failure notice in root's mail,
    but that was it.
    Thanks, Cindy
    I failed a disk in a pool:
    # zpool status -v tank
    pool: tank
    state: DEGRADED
    status: One or more devices are unavailable in response to persistent errors.
    Sufficient replicas exist for the pool to continue functioning in a
    degraded state.
    action: Determine if the device needs to be replaced, and clear the errors
    using 'zpool clear' or 'fmadm repaired', or replace the device
    with 'zpool replace'.
    scan: resilvered 944M in 0h0m with 0 errors on Mon Dec 17 10:30:05 2012
    config:
    NAME STATE READ WRITE CKSUM
    tank DEGRADED 0 0 0
    mirror-0 DEGRADED 0 0 0
    c3t1d0 ONLINE 0 0 0
    c3t2d0 UNAVAIL 0 0 0
    device details:
    c3t2d0 UNAVAIL cannot open
    status: ZFS detected errors on this device.
    The device was missing.
    see: http://support.oracle.com/msg/ZFS-8000-LR for recovery
    errors: No known data errors
    Check root's email:
    # mail
    From [email protected] Mon Dec 17 10:48:54 2012
    Date: Mon, 17 Dec 2012 10:48:54 -0700 (MST)
    From: No Access User <[email protected]>
    Message-Id: <[email protected]>
    Subject: Fault Management Event: tardis:ZFS-8000-LR
    To: [email protected]
    Content-Length: 751
    SUNW-MSG-ID: ZFS-8000-LR, TYPE: Fault, VER: 1, SEVERITY: Major
    EVENT-TIME: Mon Dec 17 10:48:53 MST 2012
    PLATFORM: SUNW,Sun-Fire-T200, CSN: 11223344, HOSTNAME: tardis
    SOURCE: zfs-diagnosis, REV: 1.0
    EVENT-ID: c2cfa39b-71f4-638e-fb44-9b223d9e0803
    DESC: ZFS device 'id1,sd@n500000e0117173e0/a' in pool 'tank' failed to open.
    AUTO-RESPONSE: An attempt will be made to activate a hot spare if available.
    IMPACT: Fault tolerance of the pool may be compromised.
    REC-ACTION: Use 'fmadm faulty' to provide a more detailed view of this event. Run 'zpool status -lx' for more information. Please refer to the associated reference document at http://support.oracle.com/msg/ZFS-8000-LR for the latest service procedures and policies regarding this diagnosis.

  • Jtree expandPath is not working

    Hi All,
    I am performing following opertion on jtree
    First i am taking path of selected jtree node.
    i am updating jtree
    then i am trying to expand jtree on the basis of selected path.
    but it is not getting expanded at all.pls help
    code --->
    TreePath treePath=tree.getSelectionPath().getParentPath();
    // below line refreshing tree with new value
    TreeStructure.CreateTreeStructure(connDialog.getConnection(), tree, connDialog.getServerName().getText());
    tree.expandPath(treePath);
    // tree.setSelectionPath(treePath);
    tree.setVisible(true);

    do u got the solution for ur problem?
    if no
    this thread show the error source
    http://forum.java.sun.com/thread.jspa?threadID=674858
    else
    tell me the solution

  • ReportDocument.Load() Extremely slow and frustrating!

    Hi,
    We have 3 workstations all with exactly the same hardware specs. The software specs are as follows:
    Machine 1 - Win XP, VS 2008, CR 2008, SQL 2005
    Machine 2 - Vista Business, VS 2008, CR 2008, SQL 2005
    Machine 3 - Vista Business, VS 2008, CR 2008, SQL 2008
    All the crystal assemblies are version 12.x
    All of the machines are loading the exact same report files, and running the exact same code to do this, i.e the same project in VS.
    Machine 1 takes about 5-7 seconds for the first load, then every other load after that, regardless of if it's the same report over and over, or different ones each time, take about 3-5 seconds.
    Machine 2 takes about 5-7 seconds for the first load, then every other load after that, as above, regardless of if it's the same or a different report takes about 1 second to load.
    Machine 3 takes anywhere from 1 minute up to two minutes, for the first and every other time a report is loaded.
    We are stumped and have no idea what could be causing this.
    Regards,
    Paul M.

    > Machine 1 - Win XP, VS 2008, CR 2008, SQL 2005
    > Machine 2 - Vista Business, VS 2008, CR 2008, SQL 2005
    > Machine 3 - Vista Business, VS 2008, CR 2008, SQL 2008
    So if you connect to SQL 2005 from Machine 3, do you get the same slow performance?
    Sincerely,
    Ted Ueda

  • BT Home Move - a night mare (extremely disappointe...

    I am moving flat on 2nd July in the same building and moving to next door. I thought it will be a quick process for BT to move my home telephone line but it was not the case. Since I am trying to resolve the issues which triggered after my first call on 20th June (Monday), I'm still not sure when my BT line will be moved.
    Please see below for various orders placed during last week:
    VOL011-51*********
    VOL011-51*********
    VOL011-51*********
    VOL011-51*********
    20 June 2011
    I called around lunch time and talked to a nice lady who took 45 minutes to get the order in place. There were number of occasions when I was put on hold. I told the lady that my Internet provider is a different company and by that time, I was not aware of any SIM code (Simultaneous Provide code) which is required by the broadband provider to connect Internet services. I found out about this code when I called my broadband provider. Now I called back around 5PM and requested SIM code. BT representative told me to cancel your order so as you can place a new order and then I will be issued a new SIM code.
    21 June 2011
    As per BT representative's advice, I called again after 5PM and requested a new order. BT representative said the order is not cancelled and you need to speak to our 'Open Order' team. I said 'OK' fine, I will talk to them. I spoke to the guy in that team and he said the order is cancelled. He then connected me to the home move team again and I placed a new order. Now, next day 22 June 2011, I got message on my mobile that your order is cancelled.
    22 June 2011
    After receiving the text, I called again BT and enquired about my order? They said system problem and you need to place a new order. You need to wait for another 24 hours so as the system can be clear completely.
    23 June 2011
    I gave up and asked my wife to give you guys a call for home move. She spent an hour to arrange home move but incorrectly requested the closing date as 4th July instead of 8th July as I got keys for both flats until 9th July. I asked her to call you guys again and then BT said you need to wait for 3 days to cancel this out. She called again on the same day and requested if this could be done more quickly and the Open Order team said you can request another order after 24 hours.
    24 June 2011
    Then we called again on Friday 24th June and we heard the same story that the system did not cancel it completely and call again on Monday.
    27 June 2011
    We called again today and again we've been told the same story that you need to wait for another 24 hours for system to be updated and your order is placed as provisionally. My new moving date will be:
    Switching off: 8th July and
    Switching on: 13 July
    Please some body can tell me what kind of system BT uses for its order management system?
    Why there is no Super User/ Supervisor who can remove the order from the system?
    We spent around 10 hours in sorting this out and the big picture is, we're still not sure when our services will resume once it's switched off as it's all provisional booking. It's an extreme level of frustration which I can not explain. Due to this issue, I need to go to office on Saturday 9th July by travelling a 12 miles journey because I can work from home but due to unavailability of BT, I've no internet. Who will pay the cost?
    If you guys are not capable enough, then please ask your customers to leave and BT should not charge any cancellation charges so as they can freely see other options/ providers.
    I called BT on 20th June to arrange home move. The lady took at least 45 minutes to get the order in place.

    Hi Maaz, first of all do you want to go back to your post and edit out(****) some of the  VOL numbers.
    Secondly this is a customer to customer forum the only BT representatives on here are the mods. They should be able to help you if you fill out this form. 
    It might take a couple of days before the pick up the message.
    Form is here: http://bt.custhelp.com/app/contact_email/c/4951
    toekneem
    http://www.no2nuisancecalls.net
    (EASBF)

  • Problem Expanding certain paths in a JTree

    I am working with a JTree and trying to do the following:
    My JTree is initially defined using the following code:
    rootNode = new DefaultMutableTreeNode();
    DefaultTreeModel treeModel = new DefaultTreeModel(rootNode);
    tree = new JTree(treeModel);
    //treeListener = new TreeSelectionListener();
    tree.addTreeSelectionListener(treeListener);
    DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
    renderer.setLeafIcon(null);
    tree.setCellRenderer(renderer);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    tree.setShowsRootHandles(true);
    tree.setAutoscrolls(true);
    tree.setExpandsSelectedPaths(true);
    When a user selects a node, and presses some button, I get and save the current path (of the selected component) like this:
    TreePath currentPath = tree.getSelectionPath();
    Then I do some action on it, then repopulate the JTree
    I have the following code at the bottom of the JTree populating method in an effort to expand the path in the tree which was last selected:
    tree.expandPath(currentPath);
    tree.setVisible(true);
    tree.updateUI();
    The problem is that when the tree repopulates, it stays completely collapsed, and I can't seem to figure out how automatically make it viewable in an expanded state (I don't want the user to have to go expand each expandable node by clicking beside it)
    Does anyone know how to either expand the whole tree from the very beginning, or expand just the selected path?
    Thanks in advance for your help,
    Noha

    To expand on path there is jtree.expandPath(treepath);
    To expand the whole tree, I wrote a recursive method.

  • JTree selection problem

    I have a problem trying to select a node of a JTree using JDK 1.3.1 and JDK 1.4 beta 3. I use a JTree with a DefaultTreeModel and DefaultMutableTreeNodes.
    Before the tree became visible it has all the nodes loaded but not visible. Then I want to select a path of the tree using a node (DefaultMutableTreeNode) but I not able to do it.
    The path isn't selected and isn't visible.
    I use the following code:
      jTree.setExpandsSelectedPaths(true)
      jTree.setSelectionPath(new TreePath(node.getPath()));
      //I've also tried with
      jTree.expandPath(new TreePath(dmtn.getPath()));Thanks.

    Fair enough. I guess I need to do a bit more reading.
    You have to create a new TreePath object because the
    getPath() method of DefaultMutableTreeNode returns an
    array of TreeNodes where as the setSelected method of
    JTree requires a TreePath object.
    Why are you creating a new path with the contents ofa
    call to getPath?
    wouldn't node.getPath() be what you want toexpend/set
    visible/scroll to etc
    try it without creating a new TreePath

  • Expand a path in JTree

    Hi all. Please help, I am trying to programmatically expand JTree with JTree.expandPath(path), but it only works one level downwards from the last physically selected node. Is this a bug, or am I doing something wrong?

    If you are using DefaultMutableTreeNode for your nodes, thenTreePath tp = new TreePath(theNode.getPath());gets you a path from the root to theNode. If you want that to be the selection, thentheTree.setSelectionPath(tp);and if you want it to be expanded and viewable thentheTree.expandPath(tp);If you aren't using DefaultMutableTreeNode, you will have to build the TreeNode[] that contains the nodes from the root down to theNode by some kind of loop; the rest of the code still works.

  • Mobile data extremely slow after iOS update 8.1.3

    After I updated to iOS 8.1.3, my data speed works like at 2G speed. My phone says its still has LTE, but it's definitely not. Even when I turn off the LTE, and my phone is connected to 3G, it's still incredibly slow. I've also tried restoring the phone, turning on and off data roaming, and of course restarting my phone countless times. I have net10, which runs on AT&T towers in my area. I used to have iOS 8.1.2 before I updated. I'm preety tech savvy, but I haven't been able to fix this. It's extremely annoying and frustrating to have such slow internet since I'm away from wifi for most of the day. Any help?

    So I called Net10 today and this time the customer representive that I spoke to knew what to do. They basically ended up resetting my data connection and it was good to go afterwards. 

  • Grouped table doesn't update underlying JTree

    I'm having a problem getting a groupable JTable to work. The JTable has an underlying JTree which is used to group on a specific column. The table can expand and retract it's nodes perfectly however when I call JTree.expandPath it doesn't update the table view immediately, instead it updates after a call to showVisible on a dialog.
    My question is; when does the view of a table get updated after having called expandPath on a tree. From my perspective at least it seems it doesn't expand it immediately on the call to expandPath. Do I need to a function like refresh to model?
    Thanks for the help!
    EDIT: My assumption is it has something to do with the same reason why doing :
    setVisible(false)
    setVisible(true)
    and stepping through those statements doesn't produce changes in the UI. Is there some kind of commit method in Swing?
    Edited by: alex.p on 29-Nov-2010 03:58

    I've used this basic code structure before:
    DefaultTreeModel model = (DefaultTreeModel)tree.getModel();
    DefaultMutableTreeNode root = (DefaultMutableTreeNode)model.getRoot();
    root.add(new DefaultMutableTreeNode("another_child"));
    model.reload(root);If you need further help then you need to create a "Short, Self Contained, Compilable and Executable, Example Program (SSCCE)", that demonstrates the incorrect behaviour.
    http://homepage1.nifty.com/algafield/sscce.html
    Don't forget to use the "Code Formatting Tags", so the posted code retains its original formatting.
    http://forum.java.sun.com/help.jspa?sec=formatting

  • Execption while using tree.expandPath() method??

    Hi,
    I have a JTree and on expanding the Jtree and Saving it I save the path of the tree stuture in a file as Text
    i.e I take the TreePath from the JTree and save it in the file as
    treePath.toString();
    Now loading it again,I take the Text back suppose the text to be
    "Simulation root, Flowsheet, Units, CD01"
    I create the TreePath object by calling
    TreePath th=new TreePath("Simulation root, Flowsheet, Units, CD04");
    tree.expandPath(th);but while executing the tree.expandPath(th); it gives the following error
    ----------------------Exception------------------------------------
    java.lang.ClassCastException
         at javax.swing.tree.DefaultTreeModel.isLeaf(DefaultTreeModel.java:185)
         at javax.swing.JTree.expandPath(JTree.java:1733)
         at jTreeApi.OwnTreeSelectionListener.valueChanged(OwnTreeSelectionListener.java:188)
         at javax.swing.JTree.fireValueChanged(JTree.java:2392)
         at javax.swing.JTree$TreeSelectionRedirector.valueChanged(JTree.java:2763)
         at javax.swing.tree.DefaultTreeSelectionModel.fireValueChanged(DefaultTreeSelectionModel.java:629)
         at javax.swing.tree.DefaultTreeSelectionModel.notifyPathChange(DefaultTreeSelectionModel.java:1076)
         at javax.swing.tree.DefaultTreeSelectionModel.removeSelectionPaths(DefaultTreeSelectionModel.java:497)
         at javax.swing.JTree.removeDescendantSelectedPaths(JTree.java:3084)
         at javax.swing.JTree.setExpandedState(JTree.java:2976)
    Any idea where I am making it wrong.
    Thanks
    Neel

    so whats the solution then
    I even tried this
    DefaultMutableTreeNode x[]=new DefaultMutableTreeNode[4];
                        x[0]=new DefaultMutableTreeNode("Simulation root");
                        x[1]=new DefaultMutableTreeNode("Flowsheet");
                        x[2]=new DefaultMutableTreeNode("Units");
                        x[3]=new DefaultMutableTreeNode("CD04");
                        TreePath th=new TreePath(x);
                        tree.expandPath(th);Even this is not working..
    So how should I do this...Any idea/logic ????
    thnx
    Neel

  • Airport Express; Seriously unreliable and frustrating. Please Help?

    Hi Guys,
    I'm a bit of a novice with Macs but not to the extent that I can't follow some some simple instructuons !
    I have a 2009 Unibody Macbook Pro running OSX 10.8.5 and use an Airport Express 2nd generation to send music from iTunes to the Express and then a phono cable from the Airport Express to my hi fi. The Express is no more that 2 meters away, yes ONLY two meters away yet it's always been very unreliable.
    I find that when I wake in the morning and switch everything on then double click an internet radio station I have in itunes that the Airport Express will be located after a little while and begin playing sound thorugh to my speakers.
    If how ever I switch everything on and leave it for longer that 3 minute then click an sound file in iTunes that iTunes or Airport Utility can't locate the Express.
    Also if I then switch off the Express and back on after only a short while iTunes or Airport utility still doesn't find it. I find that I have to switch it off for much longer periods then make sure I start playing music in iTunes right away or I'll miss a window of connection if I get one at all or then again the Airport Express wont be detected.
    I've tried a soft re-set and a hard re-set but this doesn't change any thing.
    To me The Airport Express is extremely unrealible and frustrating to use.
    Can any of you suggest what else I could try that would enable to me to more reliably connect and send music to my Airport Express?
    Cheers guys,
    Dan

    Keeping saying that somthing is a bad product when a) you are not that technical and b) new to mac is not really fair now is it.   I've got 6 Airports in Total - 4 AE 1 time machine and one old Extreme - they all work perfectly together. And the correct network configuration is always tricky. Most people never set it up right.
    We are here to help!
    Personally I have issues with Virgin's Super Hub and resorted to turning off the Wifi and router part of it, so it's just a modem and having an Airport express be a Router and I have 4 others connecting to that.
    Not for your problem... If you don't need the signal boost and are happy with the connection in the house, certainly in the room you are in then just 'Join a network' Way simpler and will not cause possible network conflictions.
    For example if you try and extend a network you can sometimes get double nat errors.   What you don't want it for the Airport AND the BT hub to act as routers on the same network  - you only want one.
    Also, just did some more research on here 'airport and homehub' The BT hub appears to not have Open WDS standards.  So more than likely that is your issue if you are trying to extend the network. May work for a while then fall over.
    Another thing to check is the Wireless security type on your home hub it seems.  Both should be the same.
    WEP  (Avoid!)
    WPA2 - PSK - AES
    WPA - PSK - TKIP
    WPA/WPA2 Personal
    WPA2 Personal

  • Filtering JTree help

    Hello,
    I have a situation where 10,000+ records are organized in a JTree. To make it easier on my users, I would like to allow them to filter the records through a text field. SInce there are so many records, I do not want to filter the whole set. Instead, I would like to filter the children of the currently selected node. if no node is selected, filter only the "top" (level below hidden root).
    I searched the forums on how to filter JTrees, and I thought I had pieced together a working filter model. Once I tried it, I ran into the following error:
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException: Null chil
    d not allowed
    at javax.swing.tree.TreePath.pathByAddingChild(Unknown Source)
    at javax.swing.tree.VariableHeightLayoutCache$TreeStateNode.setParent(Un
    known Source)
    at javax.swing.tree.DefaultMutableTreeNode.insert(Unknown Source)
    at javax.swing.tree.DefaultMutableTreeNode.add(Unknown Source)
    at javax.swing.tree.VariableHeightLayoutCache$TreeStateNode.expand(Unkno
    wn Source)
    at javax.swing.tree.VariableHeightLayoutCache$TreeStateNode.expand(Unkno
    wn Source)
    at javax.swing.tree.VariableHeightLayoutCache.ensurePathIsExpanded(Unkno
    wn Source)
    at javax.swing.tree.VariableHeightLayoutCache.setExpandedState(Unknown S
    ource)
    at javax.swing.plaf.basic.BasicTreeUI.updateExpandedDescendants(Unknown
    Source)
    at javax.swing.plaf.basic.BasicTreeUI$Handler.treeExpanded(Unknown Sourc
    e)
    at javax.swing.JTree.fireTreeExpanded(Unknown Source)
    at javax.swing.JTree.setExpandedState(Unknown Source)
    at javax.swing.JTree.expandPath(Unknown Source)
    at javax.swing.plaf.basic.BasicTreeUI.toggleExpandState(Unknown Source)
    at javax.swing.plaf.basic.BasicTreeUI.selectPathForEvent(Unknown Source)
    at javax.swing.plaf.basic.BasicTreeUI$Handler.handleSelectionImpl(Unknow
    n Source)
    at javax.swing.plaf.basic.BasicTreeUI$Handler.handleSelection(Unknown So
    urce)
    at javax.swing.plaf.basic.BasicTreeUI$Handler.mousePressed(Unknown Sourc
    e)
    at java.awt.AWTEventMulticaster.mousePressed(Unknown Source)
    at java.awt.AWTEventMulticaster.mousePressed(Unknown Source)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at javax.swing.JComponent.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)
    This occurs when I am expanding the filtered JTree, usually about 2 or 3 levels in (not counting hidden root).
    Below is my filter JTree Model class:
    public class FilteredJTreeModel extends DefaultTreeModel{
        String filterString=null;
         private DefaultTreeModel delegate;
         private TreeNode selectedNode=null;
        /** Creates a new instance of FilteredJTreeModel */
         public FilteredJTreeModel(DefaultTreeModel delegate){
             super((TreeNode) delegate.getRoot());
             this.delegate=delegate;
        public void refilter(String fylter, TreeNode levelNode){
            filterString=fylter;
            selectedNode=levelNode;
            setFilter(true, levelNode);
        public void setFilter(boolean pass, TreeNode aNode){
            final TreeNode root=aNode;
            final int childCount = root.getChildCount();
            final int[] indices = new int[childCount];
            final Object[] children = new Object[childCount];
            for(int i=0; i<childCount; i++){
                indices=i;
    children[i] = getChild(root, i);
    fireTreeStructureChanged(this, new Object[]{root}, indices, children);
    public int getChildCount(Object parent){
    int count=0;
    for(int i=0; i<delegate.getChildCount(parent); i++){
    final Object child=delegate.getChild(parent, i);
    if(isShown(child)){
    count++;
    }else{
    return count;
    public Object getChild(Object parent, int index){
    int count=0;
    for(int i=0; i< delegate.getChildCount(parent); i++){
    final Object child=delegate.getChild(parent, i);
    if(isShown(child)){
    if(count++ == index){
    return child;
    }else{
    return null;
    return null;
    public int getIndexOfChild(Object parent, Object child){
    return delegate.getIndexOfChild(parent, child);
    public boolean isLeaf(Object node){
    if(isShown(node)){
    return delegate.isLeaf(node);
    return false;
    private boolean isShown(Object node){
    final DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode)node;
    final String objStr = treeNode.getUserObject().toString();
    if(filterString==null || filterString=="")return true;
    if(selectedNode!=null && !treeNode.isRoot()){
    TreeNode[] array=((DefaultMutableTreeNode)selectedNode).getPath();
    for(int x=0; x<array.length; x++){
    if(((DefaultMutableTreeNode)array[x]).equals(treeNode)){
    return true;
    return (objStr.indexOf(filterString, 0)!=-1);
    The code for my JTree class is:
    public class JpenoTree extends JTree{
        private FilterField filterField;
        private int DEFAULT_WIDTH=20;
        /** Creates a new instance of JpenoTree */
        public JpenoTree() {
            super();
            filterField = new FilterField(20);
            setModel(new FilteredJTreeModel((DefaultTreeModel)getModel()));
            this.addTreeSelectionListener(new TreeSelectionListener() {
                public void valueChanged(TreeSelectionEvent e) {
                    treeValueChanged(e);
        public JpenoTree(TreeNode root){
            super(root);
            filterField = new FilterField(20);
            setModel(new FilteredJTreeModel((DefaultTreeModel)getModel()));
            this.addTreeSelectionListener(new TreeSelectionListener() {
                public void valueChanged(TreeSelectionEvent e) {
                    treeValueChanged(e);
       public JpenoTree.FilterField getFilterField() {
            return filterField;
        public void treeValueChanged(TreeSelectionEvent e) {
            System.err.println("Selected Node: "+((DefaultMutableTreeNode)e.getPath().getLastPathComponent()).getUserObject().toString());
            filterField.setSelectedNode((TreeNode)e.getPath().getLastPathComponent());
        class FilterField extends JTextField implements DocumentListener{
            private TreeNode selectedNode;
            public FilterField(int width){
                super(width);
                getDocument().addDocumentListener(this);
            public void changedUpdate(DocumentEvent e){
                ((FilteredJTreeModel)getModel()).refilter(this.getText(),
                        (TreeNode)((selectedNode==null)?getModel().getRoot():selectedNode));
            public void insertUpdate(DocumentEvent e){
                ((FilteredJTreeModel)getModel()).refilter(this.getText(),
                        (TreeNode)((selectedNode==null)?getModel().getRoot():selectedNode));
            public void removeUpdate(DocumentEvent e){
                ((FilteredJTreeModel)getModel()).refilter(this.getText(),
                        (TreeNode)((selectedNode==null)?getModel().getRoot(): selectedNode));
            public void setSelectedNode(TreeNode selectedNode) {
                this.selectedNode = selectedNode;
            public TreeNode getSelectedNode() {
                return selectedNode;
    }Help is appreciated. Please bear in mind that I am new to Swing's M-V-C approach.
    Aaron

    I have something like this, and it works fine. Hope it helps.
        public Object getChild(Object parent, int index) {
            int realchildren = ((TreeNode) parent).getChildCount();
            if (filter == null) {
                return ((TreeNode) parent).getChildAt(index);
            if (realchildren == 0) {
                throw new ArrayIndexOutOfBoundsException("node has no children");
            int realIndex    = -1;
            int visibleIndex = -1;
            for (int i = 0; i < realchildren; i++) {
                TreeNodenode = (TreeNode) ((TreeNode) parent).getChildAt(i);
                if (filter.passNode(node)) {
                    visibleIndex++;
                realIndex++;
                if (visibleIndex == index) {
                    return ((TreeNode) parent).getChildAt(realIndex);
            throw new ArrayIndexOutOfBoundsException("index unmatched");
        public int getChildCount(Object parent) {
            int realchildren = ((TreeNode) parent).getChildCount();
            if (filter == null) {
                return realchildren;
            if (realchildren == 0) {
                return 0;
            int count = 0;
            for (int i = 0; i < realchildren; i++) {
                TreeNodenode = (TreeNode) ((TreeNode) parent).getChildAt(i);
                if (filter.passNode(node)) {
                    count++;
            return count;
        }

Maybe you are looking for

  • Error Message when trying to open PDF

    I keep getting this msg: Adobe Reader could not open 'auction2015.pdf' because it is either not a supported file type or because the file has been damaged (for example, it was sent as an email attachment and wasn't correctly decoded). I can't seem to

  • My iPod touch isn't recognized by my pc.

    I've tried everything. I've made sure the iPod was fully charged, I've rebooted the pc. I've reset the iPod. I've re-installed iTunes. I've even allowed the iPod battery to go completely dead hoping that would help to reset it. Nothing has helped so

  • SunPKCS11 and NSS on Mac OS X 10.5

    Hello there, I've been scratching my head the whole day about how to use the SunPKCS11 provider and Mozilla's NSS framework under Mac OS X 10.5 (a.k.a Leopard). Let me replay the whole movie for you... So here I am, religiously following Sun's guidel

  • How to reference /inherit property class in form in oracle apps

    Hi I had a Form which is register in the oracle apps but now i have another requirement to create a tab canvas put all fields of pervoius form(content form) into new tab page canvas now i want to know how i can reference/inherit the pervious conent f

  • Powershell Event - email notification / stop / restart question

    Hey guys,       I have a filesystemwatcher app running to process files to a sql and ms access database. It works fairly well. However sometimes it goes down for really no particular reason that i can tell.  So im trying to do two things if at all po