How to set selected JTree from outside?

I have a JTree for example
-A
  -a
  -b
  -c
-B
  -a
  -b
  -c
-C
  -a
  -b
  -cif the tree is All expand , it is easy to select the the tree by setSelectionRow(5), the result is "B.a", but how to select the the tree if all collap
-A
-B
-C
{code}
let say i want to select "B.c", it can't use setSelectionRow(7) becouse the row between 0-2. So how to select the tree if the tree is *collap*?
thx..                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

i had try use setSelectionPath but still can't wotk
this sample code:
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JTree;
import javax.swing.tree.*;
import javax.swing.*;
public class test_tree extends JFrame{
    JTree tree;
    DefaultMutableTreeNode root_tree;
    test_tree(){
        //DefaultMutableTreeNode root_tree = new DefaultMutableTreeNode("Root",true);
        root_tree = new DefaultMutableTreeNode();
        DefaultMutableTreeNode child_tree;
        DefaultMutableTreeNode child_tree2;
        DefaultMutableTreeNode child_tree3;
        child_tree = new DefaultMutableTreeNode("A1",true);
        child_tree.add(new DefaultMutableTreeNode("A1.1",false));
        child_tree.add(new DefaultMutableTreeNode("A1.2",false));
        child_tree.add(new DefaultMutableTreeNode("A1.3",false));
        child_tree2 = new DefaultMutableTreeNode("B2",true);
        child_tree2.add(new DefaultMutableTreeNode("B2.1",false));
        child_tree2.add(new DefaultMutableTreeNode("B2.2",false));
        child_tree2.add(new DefaultMutableTreeNode("B2.4",false));
        child_tree3 = new DefaultMutableTreeNode("C3",true);
        child_tree3.add(new DefaultMutableTreeNode("C3.1",false));
        child_tree3.add(new DefaultMutableTreeNode("C3.2",false));
        child_tree3.add(new DefaultMutableTreeNode("C3.3",false));
        root_tree.add( child_tree);
        root_tree.add( child_tree2);
        root_tree.add( child_tree3);
        tree = new JTree(root_tree);
        tree.setRootVisible(false);
        tree.setSize(100,300);
        add(tree);
        JButton bt = new JButton("witPath");
        bt.setSize(new Dimension (80, 30));
        bt.setLocation(200,100);
        bt.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                tree.expandPath(new TreePath(root_tree.getNextNode().getChildAt(1)) );
                tree.setSelectionPath(new TreePath(root_tree.getNextNode().getChildAt(1)) );
        add(bt);
        JButton br = new JButton("witROW");
        br.setSize(new Dimension (80, 30));
        br.setLocation(200,150);
        br.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                tree.expandRow(1);
                tree.setSelectionRow(3);
        add(br);
        setSize(400,400);
        setLayout(null);
        setVisible(true);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     public static void main(String args[]){
            new test_tree();
}thx..

Similar Messages

  • How to set selected Language from Portal dropdown in Logon to User profile

    Hi Gurus,
    I select a language in Portal Language dropdown in the Logon Page.
    After login in the content is getting displayed in the browser language.
    I want the portal content to be displayed in the selected language in the portal LogonPage.
    I checked the thread Logon page change to add a dropdown for language
    The is the requirement for me too .
    Kindly suggest me on how to set the language in the Portal user Profile so that the portal contents gets displayed in the selected languages from the dropdown .
    Thanks in Advance

    Hi Prasanna,
    The language that the portal is displayed in depends on the following
    heirarchy, with the languages at the top of the list taking precedence
    over those at the bottom:
    1. Component (iview) language (defined in the portalapp.xml)
    2. Portal Mandatory language (defined in the prtDefault.properties)
    3. User language (defined in the user#s profile).
    4. Request language (defined by the browser).
    5. Portal Default language (defined in the prtDefault.properties)
    6. System Default language (default locale defined by the OS).
    So for example, if you have your portal user language (as in point 3)
    set to Russian, but the language of the iView that is the logon page
    (as in point 1) set to English, that logon page will be displayed in
    English.
    Keeping the above in mind, please make the necessary changes to the
    configurations and check if it helps.
    Regards,
    Sowmya
    Edited by: Sowmya K on Jun 2, 2011 11:32 AM

  • How to get selected value from selectOneRadio ???

    Hi...i want to how to get selected value from selectOneRadio and use it in another page and in backing bean.
    Note i have about 10 selectOneRadio group in one page i want to know value of each one of them.
    Plzzzzzzzz i need help

    You have a datatable in which each row is a question, correct?
    Also in each row you have 5 possible answers that are in a radio, correct?
    So,
    You need to put in your datatable model, a question, and a list of answers (5 in yor case) and the selected one.
    So you will have a get to the question, an SelectItem[] list to populate the radios and another get/set to the selected question.
    ex:
    <h:selectOneRadio value="#{notas.selectedString}" id="rb">
    <f:selectItem itemValue="#{notas.valuesList}"/>
    </h:selectOneRadio>
    Search the web for examples like yours.

  • How to set a language from LTR to RTL in illustrator cs4

    how to set a language from LTR to RTL in illustrator cs4.....plz help

    Mac or PC
    In either case the language has to be selected on the Mac go to the SystemPreference and language and text and select arabic as the language etc.
    That should do it.
    Oh, yes just in case you have to also select and arabic type face and it helps if you have a ME computer.

  • How to import select photos from Iphoto into Adobe Elements

    How to import select photos from Iphoto into Adobe Elements

    If you wish to import in Elements Organizer here is the guide to help you out with all you need to use iPhoto and Organizer. http://helpx.adobe.com/elements-organizer/using/import-media-iphoto-library-mac.html
    If you wish to set PSE Editor as your editor for iPhoto images then here is the help link to guide you for the same - http://helpx.adobe.com/photoshop-elements/kb/photoshop-elements-iphoto-mac-os.html
    Hope it helps.
    Thanks,
    Garry

  • How to get selected value from OADefaultListBean.

    Hi All,
    How to get selected value from OADefaultListBean ?
    Thanks,

    Hi,
    To identify the user's selection(s) when the page is submitted, you would add the following logic to your processFormRequest() method:
    OADefaultListBean list =
    (OADefaultListBean)webBean.findChildRecursive("positionsList");
    String name = list.getName();
    String[] selectedValues = pageContext.getParameterValues(name);
    To retrieve all the values in the list box, call list.getOptionsData().
    --Prasanna                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How to get selected values from selectManyCheckbox ?

    Hi,
    I am a SOA developer and using 'Auto generated adf form' of Human Task. I did some customization in the form. I need to show one dynamic list (contains multiple string values) on a form, from which user will select desired values. For this I have used <af:selectManyCheckbox> adf component.
    It has generated code as follows...
    <af:selectManyCheckbox value="#{bindings.Response.inputValue}"
                                             label="#{bindings.Response.label}"
                                             id="smc1">
                        <f:selectItems value="#{bindings.Response.items}" id="si9"/>
    </af:selectManyCheckbox>
    I am able to show list on a form and can select multiple values also.
    Now, I want the multiple selected values back in my BPEL process. I need only those values which are selected by user.
    Currently I am getting complete list as it is back in BPEL process.
    Please help me out..!
    Thanks..
    Suraj

    Unwinding ADF: How to retrieve Selected Items from selectManyCheckbox using ValueChnageListener

  • How to insert select columns from one internal table to another

    Hi,
    How to insert select columns from one internal table to another based on condition as we do from a standart table to internal table.
    regards,
    Sriram

    Hi,
    If your question is for copying data from 1 int table to other ;
    we can use
    APPEND LINES OF it_1 TO it_2.
    or if they have different columns then:
    loop at it_1 into wa_it1.
    move wa_it1-data to wa_it2-d1.
    apped wa_it2 to it_2.
    clear wa_it2.
    endloop.
    thnxz

  • TS4006 how to set a tracking from the computer if someone stolen the ipod

    how to set a tracking from the computer if someone stolen the ipod

    Welcome to the Apple Community.
    You can only locate your device when it is logged into iCloud and 'Find My Phone' is enabled, additionally the device will need to be switched on and connected to a wifi or cellular network.
    Unfortunately, you cannot activate iCloud or 'Find My Phone' remotely.

  • How can I select columns from a table EMP, using Select statement?.

    Hi Friends,
    How can I select columns from a table EMP?.
    I want to select columns of EMP table, using select statement.
    Please reply me urgently.
    Shahzad

    Something like this:
    scott@DBA> select empno,ename,job from emp;
         EMPNO ENAME      JOB
          7369 SMITH      CLERK
          7499 ALLEN      SALESMAN
          7521 WARD       SALESMAN
          7566 JONES      MANAGER
          7654 MARTIN     SALESMAN
          7698 BLAKE      MANAGER
          7782 CLARK      MANAGER
          7788 SCOTT      ANALYST
          7839 KING       PRESIDENT
          7844 TURNER     SALESMAN
          7876 ADAMS      CLERK
          7900 JAMES      CLERK
          7902 FORD       ANALYST
          7934 MILLER     CLERK
    14 rows selected.Check the documentation:
    http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_10002.htm#sthref9697
    Message was edited by:
    Delfino Nunez

  • How to set up printer from ipad?

    how to set up printer from ipad?
    Johs.

    iOS AirPrint Printers  http://support.apple.com/kb/HT4356
    How to Print from Your iPad: Summary of Printer and Printing Options
    http://ipadacademy.com/2012/03/how-to-print-from-your-ipad-summary-of-printer-an d-printing-options
    Print from iPad / iPhone without AirPrint
    http://ipadhelp.com/ipad-help/print-from-ipad-iphone-without-airprint/
    How to Enable AirPrint on a Mac and Use Any Printer
    http://ipadhelp.com/ipad-help/how-to-use-airprint-with-any-printer/
     Cheers, Tom

  • How to set iframe src from java dynammically

    Hi,
    Iam calling a servlet from jsp and servlet calls the databse query and returns the value,
    in my jsp i have ifrme, i want to change the source of iframe from java depends on the result from database , and the result must display on the iframe can any one tell me how to do this

    aurelian_cl wrote:
    I need to know how to set environment variables from java
    I want to set from java for example the environment variable "TestVar" with the value "TestValue"!1) That functionality does not belong in an application. You're trying to set environment variables, which are global across all applications, at either the user level as a whole, or across the entire machine (system level). Or, if you're only trying to set a variable active for the current process, you don't need to do that.
    2) Environment variables are not a platform-independent entity, and are thus against the nature of Java.
    My gut feel is that you are designing something in a backwards way, so my point is mainly to point that out, not to try to help you solve that particular problem.

  • How to set selected radioButton

    Hi,
    There are tons of examples on the websites to show you how to detect selected radioButton or click event. But It is not easy to find aone example to show you how to set selected radioButton.
    Here is my code, but not working, Is it not well handle on it for Flex?
    [Bindable]       
    private var selectedRadioButton:RadioButton;
    private function initSelect(): void {
            selectedRadioButton = rb1;
    <mx:RadioButtonGroup id="rbg" selection="{selectedRadioButton}"
                       change="rbg_change(event);" />
                    <mx:HBox>
                  <mx:RadioButton id="rb1"
                          label="Active" group="{rbg}" />
                  <mx:RadioButton id="rb2"
                          label="Lock" group="{rbg}" />
    </mx:HBox>
    Thanks

    it's simple set its selected property true. For instance
    myRadioButtonSelectedOnStart.selected="true"
    Sincerely,
    Michael
    El 14/05/2009, a las 10:32, "master.card" <[email protected]> escribió:
    >
    Hi,
    >
    There are tons of examples on the websites to show you how to detect 
    selected radioButton or click event. But It is not easy to find aone 
    example to show you how to set selected radioButton.
    >
    Here is my code, but not working, Is it not well handle on it for 
    Flex?
    >
    private var selectedRadioButton:RadioButton;
    private function initSelect(): void {
            selectedRadioButton = rb1;
    <mx:RadioButtonGroup id="rbg" selection=""
                       change="rbg_change(event);" />
                    <mx:HBox>
                  <mx:RadioButton id="rb1"
                          label="Active" group="" />
    >               <mx:RadioButton id="rb2"
    >                       label="Lock" group="" />
    </mx:HBox>
    >
    >
    >
    Thanks
    >

  • How's to select data from structure data object?

    Dear Guru,
    If my data is kept in structure data object (not a table type).  How can I select data from that kind of data object.  Thank you.
    Cheers,

    Hi,
    Data cannot be stored in structure.
    Structure is just like a view , so its a medium with which you can create a view relevant to your needs.
    The fields that we need together , we put in a structure.
    Structure is a medium where we collect all our relevant fields.
    we can include the structure in internal table so that we can actually store data , process data and retrieve data.
    hope this helps.
    thanx,
    dhanashri.

  • How can buy iPhone 5 from outside USA ?. And how much it cost ?

    How can buy iPhone 5 from outside USA ?  iPhone 5 - 16 GB  how much it cost ?

    Unless you live in the US & plan on using the iPhone 5 in the US, you DO NOT want a US iPhone 5. Apple will sell three different variants of the iPhone 5. The model sold in the US will only work, for LTE, in the US & Canada...no where else. You've been warned.

Maybe you are looking for