Jtree selection problem.....help

hi,
I have a desktoppane....inside i m opening some internal frame.....
also i have a tree class....which has any leaf name as internal frame title
my question is ...when i selected any internal frame it should show selected leaf according to the internal frame activate title.....
like we have in VB...when we select any form ...it select corresponding leaf also..
i wanna do same...
i using code alike this
public void internalFrameActivated(InternalFrameEvent e)
                                                  DefaultMutableTreeNode dmt=new DefaultMutableTreeNode(getTitle());
                    TreePath pp=new TreePath(dmt.getPath());
                                        tree.expandPath(pp);
          tree.setSelectionPath(pp);
          tree.fireTreeExpanded(pp);*/
but it's not showing selected leaf...even though it's getting correct path
regards
Tarique

Hi Frank,
Atlast i made it to work.
TreePath tp = mBalanceInfoTree.getSelectionPath();
StringTokenizer st = new StringTokenizer(tp.toString(), ",");
String bal_Grp[] = new String[st.countTokens()];
int count = 0;
while (st.hasMoreElements()) {
bal_Grp[count] = st.nextToken();
count++;
Thanks for your replies..
N correct me if there is any wrong in this approach.
Cheers
SS

Similar Messages

  • JTree selection problem when using custom renderer and editor

    Hello:
    I created a JTree with custom renderer and editor.
    The customization makes JCheckBox to be the component
    responsible for editing and rendering.
    The problem is that when I click on the node with the checkbox
    the JTree selection model does not get updated.
    Without customizations of the editor and renderer the MouseEvent would be fired and BasicTreeUI$MouseHandler.mousePressed() method would call
    the selectPathForEvent() method which would be responsible for updating
    the selection model. At the same time if I attach a mouse listener to the JTree (customized) I see the events when clicking on the nodes. It seems like the MouseEvent gets lost and somehow as a result of which the selection model does not get updated.
    Am I missing something?
    Thanks
    Alexander

    You probably forgot to call super.getTreeCellRendererComponent(...) at the beginning of your getTreeCellRendererComponent(...) method in your custom renderer.
    Or maybe in the getTreeCellEditorComponent(...) of the TreeCellEditor...

  • JTree Selection problem. Plz help...

    Hi All,
    I hv designed a JTree with DefaultMutableTreeNode. And i hv added TreeSelectionListener to it. When i select the nodes of the tree i hv to display the RootNode name of the tree in a label. I'm able to achieve it using
    DefaultMutableTreeNode node =(DefaultMutableTreeNode) mBalanceInfoTree.getLastSelectedPathComponent();
    TextField.setText(node.getParent());
    the problem is when i click on the RootNode it is displaying as "RootNode" but not the node name.
    Can anyone help me on this.
    Thanks in advance
    ss

    Hi Frank,
    Atlast i made it to work.
    TreePath tp = mBalanceInfoTree.getSelectionPath();
    StringTokenizer st = new StringTokenizer(tp.toString(), ",");
    String bal_Grp[] = new String[st.countTokens()];
    int count = 0;
    while (st.hasMoreElements()) {
    bal_Grp[count] = st.nextToken();
    count++;
    Thanks for your replies..
    N correct me if there is any wrong in this approach.
    Cheers
    SS

  • 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

  • JTree refresh probleme help me please

    a can't reload my JTree from my server
    my Jtree code:
              user.add("Zeus@mxf");
              user.add("Neptune@toto");
              user.add("Ulysse@mars");
         root =new DefaultMutableTreeNode("users");
              for(int i=1; i<user.size(); i++)
              userNode = new DefaultMutableTreeNode
    (user.elementAt(i) );
                   root.add(userNode);     
              renderer.setOpenIcon(OpenIcon);
         renderer.setClosedIcon(ClosedIcon);
         renderer.setLeafIcon(PrinterIcon);
              tree=new JTree(root);
              tree.setCellRenderer(renderer);
    and if a have receive the write data i do my refresh methode:
    refresh()
    userNode = new DefaultMutableTreeNode(user.elementAt(0) );
                                  root.add(userNode);     
                                  ((DefaultTreeModel)tree.getModel()).reload();
                                  tree.treeDidChange();
                                  tree.setCellRenderer(renderer);
                                  tree.setLargeModel(true);     
                                  tree.repaint();
                                  tree.revalidate();
    why it dose not work ?????

    Sorry I have not ready examples, try to implement a method this way:
    String newUser = user.elementAt(0);
    public void addNode(String newUser){
    DefaultMutableTreeNode userNode = new DefaultMutableTreeNode(newUser);
    root.add(userNode);
    tree.getModel().nodeChanged((TreeNode)tree.getModel().getRoot());
    tree.treeDidChange();

  • Selection problem in JTextArea

    hi all
    i have a TextArea in which i have some coded charecters in a group of ten charactes i treet these ten characters as a single character ,so when i delete or insert these charactes all these charactes r deleted and no other character r inserted in between , i do it with the caretListener,
    But the problem which i face is on the selection i want to select these characters as when we select some part of the URL then it is selected completely.
    help in the prob.

    this might work
    paste some text into the textArea (ensure it contains a sequence "12345")
    click anywhere in area of 12345
    import javax.swing.*;
    import java.awt.*;
    import javax.swing.event.*;
    class Testing extends JFrame
      String specialChars = "12345";
      boolean settingCaret = false;
      public Testing()
        setSize(200,200);
        setLocation(300,200);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        final JTextArea ta = new JTextArea(10,10);
        JScrollPane sp = new JScrollPane(ta);
        sp.setPreferredSize(new Dimension(175,150));
        JPanel jp = new JPanel();
        jp.add(sp);
        getContentPane().add(jp);
        pack();
        ta.addCaretListener(new CaretListener(){
          public void caretUpdate(CaretEvent ce){
            if(settingCaret == false)
              int startPos = ta.getText().indexOf(specialChars);
              if(startPos > -1)
                if(ta.getCaretPosition() >= startPos && ta.getCaretPosition() <= startPos+specialChars.length())
                  settingCaret = true;
                  ta.setSelectionStart(startPos);
                  ta.setSelectionEnd(startPos+specialChars.length());
                settingCaret = false;
      public static void main(String[] args){new Testing().setVisible(true);}
    }

  • Selection Problem with JTable

    Hello,
    i have a selection problem with JTable. I want to allow only single cell selection and additionally limit the selection to the first column.
    I preffered the style from MS Outlook Express where you can select the email accounts to edit.
    It is a table like this:
    Account name  |   Type  |   ...
    --------------|---------|---------------------
    Hotmail       |   POP3  |
    GMX           |   IMAP  |The selection should be only avaibable at 'Hotmail' or 'GMX' - not at 'POP3', 'IMAP' or as complete row selection.
    Please help me!
    Thanks.
    Warlock

    Maybe this will helpimport java.awt.*;
    import javax.swing.*;
    public class Test3 extends JFrame {
      public Test3() {
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Container content = getContentPane();
        String[] head = {"One", "Two"};
        String[][] data = {{"R1-C1", "R1-C2"}, {"R2-C1", "R2-C2"}};
        JTable jt = new JTable(data, head);
        jt.getColumnModel().setSelectionModel(new MyTableSelectionModel());
        content.add(new JScrollPane(jt), BorderLayout.CENTER);
        jt.setCellSelectionEnabled(true);
        jt.setRowSelectionAllowed(false);
        jt.setColumnSelectionAllowed(false);
        setSize(300, 300);
        setVisible(true);
      public static void main(String[] arghs) { new Test3(); }
    class MyTableSelectionModel extends DefaultListSelectionModel {
      public void setSelectionInterval(int index0, int index1) {
        super.setSelectionInterval(0, 0);
    }

  • Print selection problem

    when i select a page to be print from my pc the page select in

    Hello. I feel your pain and frustration with the print selection problem in safari, especially in Snow Leopard. I have spent hours trawling help pages and forums etc. BUT YEE HAA (sorry got a bit excited, but it really was hours) I found the answer. So here goes.
    Click on Safari
    Scroll down to services then slide to right
    Scroll down to services preferences and click
    Scroll down to the Text section
    If you Tick the Text box it will choose all options for you. Or if you don't want all options in the Text list, then untick Text box and tick options you do want.
    BUT for your print selection problem make sure you tick NEW TEXT EDIT WINDOW CONTAINING SELECTION.
    Then when you want to select something in a web page you want to print (including pictures etc) then highlight it, then Right click. And low and behold, in the list is NEW TEXT EDIT WINDOW CONTAINING SELECTION. Click that, Then press cmd+p and your printing.
    I really hope that helps with your problem
    I can now go to sleep.

  • At Line selection problem

    hi,
    iam stuck up with AT LINE-SELECTION problem ie i designed a screen where they need month list on clicking F4. i got the month list using month_names_get in the screen but while clicking the relevant month no.it's not entering into the required parameter. i have attached the codings,
    MODULE MONTH_DIS OUTPUT.
      SUPPRESS DIALOG.
      LEAVE TO LIST-PROCESSING AND RETURN TO SCREEN 0.
      SET PF-STATUS SPACE.
      NEW-PAGE NO-TITLE.
      WRITE:/ 'SELECT MONTH' COLOR COL_HEADING.
      ULINE.
      DATA: T_MNTH LIKE T247 OCCURS 12 WITH HEADER LINE.
      refresh t_mnth.
      CALL FUNCTION 'MONTH_NAMES_GET'
       EXPORTING
         LANGUAGE                    = SY-LANGU
    IMPORTING
      RETURN_CODE                 =
        TABLES
          MONTH_NAMES                 = T_MNTH
       EXCEPTIONS
         MONTH_NAMES_NOT_FOUND       = 1
         OTHERS                      = 2
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      loop at t_mnth.
        write:/ t_mnth-mnr, t_mnth-ltx.
      endloop.
      CLEAR T_MNTH-MNR.
    ENDMODULE.                 " MONTH_DIS  OUTPUT
    AT LINE-SELECTION.
      p_period = t_mnth-mnr.
      CHECK NOT p_period IS INITIAL.
      LEAVE TO SCREEN 0.
    here in the AT LINE-SELECTION, the selected month is not coming to the required parameter.
    pls help me in this issue,
    Thanks in advance,
    Premnath.

    You need to set a "Hide" after the write... I suggest you also set your own dialog PF-STATUS too so you can have just a PF2 "pick" button and a Cancel button ( this will look better to the user).
    loop at t_mnth.
      write:/ t_mnth-mnr, t_mnth-ltx.
      hide: t_mnth.  "needs this
    endloop.
    clear: t_mnth.

  • Weird BGP path selection problem

    Hi, all,
    I am seeing a weird BGP path selection problem on 4948 switch running cat4500-entservicesk9-mz.122-46.SG.bin code, this switch has two uplinks to the same ISP's different edge router, one circuit is primary the other one is strict backup, only default route is accepted from ISP. I am setting both local preference and weight to the default route advertised over backup link, however neither one is taking effect, BGP still thinks the backup link is better, what could be wrong?
    rtr#sh ip bgp 0.0.0.0/0
    BGP routing table entry for 0.0.0.0/0, version 105
    Paths: (3 available, best #2, table Default-IP-Routing-Table, not advertised to EBGP peer)
      Not advertised to any peer
      17675, (received & used)
        203.169.8.37 from 203.169.8.37 (61.211.160.150)
          Origin IGP, localpref 100, valid, external
          Community: 65001:0 no-export
      17675
        203.169.8.45 from 203.169.8.45 (61.211.160.151)
          Origin IGP, localpref 90, weight 90, valid, external, best <====
          Community: 65001:0 no-export
      17675, (received-only)
        203.169.8.45 from 203.169.8.45 (61.211.160.151)
          Origin IGP, localpref 100, valid, external
          Community: 65001:0 no-export
    Thanks

    Hi,
    On cisco routers , weight is having highest preference to decide best path. By default for received route, weight is 0 but you are setting weight 90 to backup path and that is why it is getting preferred (higher is better). Please remove weight and let local preference be 90 (lesser than route on primary path)
    --Pls dont forget to rate helpful posts--
    Regards,
    Akash

  • Prerequisites for multi selection value help

    Hi everyone,
    a couple of blogs and forum entries show multi selection value helps in VC. I, on the other hand, have so far been unable to do this. The only option I get in the first step of the value help wizard is the "single selection" type. Even if I start off with a blank form view and add a text input field I cannot choose anything apart from a single selection value help. Is there something I am completely missing? I stumbled upon a note bringing this into connection with OLAP source systems, but I can't quite see why this should change anything since the source system is not selected until step 2 of the wizard.
    Any idea on this? Thanks a lot,
    Tilman

    Hi Mario,
    thanks for the hints, I got it working now, regardless of whether you use an OLAP source system, variables or the respective input port, though. It seems to suffice to connect the query directly to a form view to get the additional options. My problem was then that I had a form view connected to a nested iview. I should be able to connect it to both a query and the iview, though.
    Thanks for your help,
    Tilman

  • Certificate selection problem in Safari

    Hi ,
    I have certifcates A,B,C,D for the same site , whenever i use the Mozilla it is asking which one to select , but somehow i dont know why Safari is asking the same option.
    It is forcing me to accept Certifcate A to that paricular site. How to solve this problem in safari.
    Regards
    Vikranth

    Hello. I feel your pain and frustration with the print selection problem in safari, especially in Snow Leopard. I have spent hours trawling help pages and forums etc. BUT YEE HAA (sorry got a bit excited, but it really was hours) I found the answer. So here goes.
    Click on Safari
    Scroll down to services then slide to right
    Scroll down to services preferences and click
    Scroll down to the Text section
    If you Tick the Text box it will choose all options for you. Or if you don't want all options in the Text list, then untick Text box and tick options you do want.
    BUT for your print selection problem make sure you tick NEW TEXT EDIT WINDOW CONTAINING SELECTION.
    Then when you want to select something in a web page you want to print (including pictures etc) then highlight it, then Right click. And low and behold, in the list is NEW TEXT EDIT WINDOW CONTAINING SELECTION. Click that, Then press cmd+p and your printing.
    I really hope that helps with your problem
    I can now go to sleep.

  • JTree select Node

    Is there any method available to select a node by its path in JTree. I have to pass the argument as string type and see the node gets selected. Help !!!!

    well, if you have the node and are using DefaultTreeModel, you can call: getPathToRoot(TreeNode)
    Not sure how to find the node from the value except to just loop thru the entire tree... or maintain a separate table of value/node objects.

  • HT2534 when i create the apple ID with the above procedure, i dont see "none" options under credit card selection, please help.

    When i create the apple ID with the above procedure, i dont see "none" options under credit card selection, please help.

    Apple needs people like you.

  • My daughter has just bought me an iPad 2 from Dubai and set it all up for me but unfortunately the iMessage function doesn't seem to work. We keep getting messages,when trying to activate it, that there is a network connection problem - help!

    My daughter has just bought me an iPad 2 from Dubai and set it all up for me but unfortunately the iMessage function doesn't seem to work. We keep getting messages,when trying to activate it, that there is a network connection problem - help!

    Thank you both for your responses but my daughter was reassured by the salesman in the iStyle store (official Apple store in the UAE) that iMessages would work but conceded that FaceTime wouldn't. My iTunes account is registered in the uk and my daughter's iPhone has iMessages even though she bought it (and uses it) in Dubai. Can anyone else throw any light on this?

Maybe you are looking for

  • Java Applet fails loading JAR files

    I'm using the OC4J setup with my Oracle forms (10g) install, this was working but no longer. I get the message below when running the test.fmx from the Oracle Forms Services test page for each of the JAR files attempting to load. I comment out the AR

  • File Adapter - Multiple Record Types to same Target

    I am currently reading in a fixed length file and loading into a table. The issue is, some of the lines in my file differ by two spaces at the end. See example below. For example, Record 1 might look like : DD/MM/YY - length of 8 Record 2 might look

  • Printing photos without a boarder

    I am posting this on behalf of a Forum member who send me a private message: Printing Photos From: fishdan To: SiobhanF on 09-29-2010 01:58 AM I have a photosmart c-5180 all-in-one. when i try to print a 8x10, the photo comes out with a one half inch

  • Unable to Update to Numbers 1.0.2

    I have Numbers version 1.0.1 which is part of the iWork '08 suite. Every time I open Numbers I get the message that a new update (v.1.0.2) is available. I click to update and get the message that I have the latest version. Yet the next time I open Nu

  • Helo regarding tns listener

    hello all when i start services it give me following error the oracleoradb10g_HOME1TNSLISTENER SERVICE ON LOCAL COMPUTER STARTED AND THEN STOPED SOME SERVICES STOP AUTOMATICALLY IF THEY HAVE NO WORK TO DO , FOR EXAMPLE THE PERFORMANCE LOG AND ALERT S