Selection Of checkbox in the JTree

Hi all,
I have a very small problem in JTree.
The JTree is with checkbox.When ever I select on the node the simultaneous chechbox is selected.
But some time with the same operation the checkbox is not selected.
Here,I attache the part of code which is responsible for my problem.
public void mouseClickedNodeSelectionListener(MouseEvent e)
        int x = e.getX();
        int y = e.getY();
        int row = tree.getRowForLocation(x, y);
        TreePath path = tree.getPathForRow(row);
        //TreePath path = tree.getSelectionPath();
        if (path != null) {
            if(/*e.getClickCount()==1 &&*/ ElmsConstants.isDoubleClicked)
                if(lastPath!=null)
                    tree.setSelectionPath(lastPath);
                return;
            lastPath = path;
            CheckNode node = (CheckNode) path.getLastPathComponent();
            int selectedId = 0;
            if(node.getElmsData()!=null)
                selectedId = (node.getElmsData().getId()).intValue();
            if(lastSelectedId==selectedId)
                boolean isSelected = !(node.isSelected());
                node.setSelected(isSelected);
                tree.updateUI();
                ((DefaultTreeModel) tree.getModel()).nodeChanged(node);
                if (row == 0) {
                    try{
                        tree.revalidate();
                        tree.repaint();
                    }catch(Exception eE)
                        System.out.println("Exception in Tree repaint");
            lastSelectedId=selectedId;
}Any Body Please help me.
Thank you,
Ananda

It's hard to say what's the problem when you post this little code.
But probably the problem is that you're listening for mouse click event.
This event only fires when you click the mouse without moving it.
If by mistake you move the mouse while you click it you will not get a mouse click event.
You can use the mousePressed or mouseReleased events instead.
Anyway I would implement this with a custom editor instead of listening to mouse events.
See example here: [http://www.java2s.com/Code/Java/Swing-JFC/CheckBoxNodeTreeSample.htm]

Similar Messages

  • Problem : Not able to select multiple checkboxes in the JTable

    Here i am trying to select the multiple check boxes in the jtable. But i am not able to do that. I set the jTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); also.
    Can any one help on this...

    [email protected] wrote:
    Here i am trying to select the multiple check boxes in the jtable. But i am not able to do that. I set the jTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); also.
    Can any one help on this...That's row selection, not check boxes. The normal way to have active checkboxes in a JTable is with an editable Boolean column. The effect of clicking such a checkbox is to cause the table to call setValueAt() in the data model with a Boolean object value, and it's up to the data model to deal with that change.

  • How could i get the selected node in the JTree

    getLastSelectedPathComponent() �returns the parent node of currenr selected, so how could I get the selected node itself in the JTree
    I will appretiate for any help!

    i think you can get by....
    TreePath treePath = tree.getSelectionPath();
    DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) treePath.getLastPathComponent();

  • How to make interaction between select many checkbox and a database ?

    Hi ;
    i'm recently setup and start to use jdev Adf faces 11g (11.1.1.3.0), and i'm trying to use a select many checkbox component.
    i want to link this select many checkbox with the result of of a select request.
    in my data object, i created an attribute as LOV (list of value), now i do not now what's the next step ??
    i will be extremely glad if you give me an example..
    thank you in advance, and please excuse my english

    See if this helps -
    Re: Many to many in ADF BC with selectManyShuttle

  • How to select a node in a JTree by name

    I have a JTree in my program. I want to programmatically set one of these nodes selected by the name of the node. I do not know how to do this. I read the "How to use trees", but no help
    Thanks!

    I have a JTree and each node on the JTree has a string name. I also have a JEditorPane that lists all these names at start up. If the user clicks on one of these names, I want to catch the HyperlinkEvent and automatically select that node in the JTree.
    So in short, I have the String name of the node that I want to programatically select.
    Thanks!

  • Problem with checkbox in the selection screen

    Hi guys,
    I have a problem with the check box in the selection screen.When i select a check box then a field in the selection screen should be enabled for entering a value.Again if i unselect the checkbox then the field should be disabled for entering a value.I have written the code in at selection-screen output.
    The problem is when i select the check box ,the field is not enabled.But when i press enter after selecting the checkbox then the field is enabled for input.It is the same when i unselect the checkbox,after i press enter only the field is getting disabled.What could be the problem.Any suggestions please?
    Thanks.

    Hi d p
                 Please try this code . I think this code have some way that you would like.
    REPORT  zdownload_to_application_server.
    TABLES : caufvd, jest.
    I N C L U D E  P R O G R A M                                        *
    *INCLUDE znrpstnd.
    Selection Screen                                                    *
    SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-t03.
    PARAMETERS: p_outb RADIOBUTTON GROUP g1 USER-COMMAND outb DEFAULT 'X' ,
                p_inb RADIOBUTTON GROUP g1.
    SELECTION-SCREEN END OF BLOCK b3.
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-t01.
    PARAMETERS : p_werks LIKE caufvd-werks MODIF ID a.        " Plant   "OBLIGATORY
    SELECT-OPTIONS  :  s_auart FOR caufvd-auart MODIF ID a,       " Order Type
                       s_aufnr FOR caufvd-aufnr MODIF ID a.       " Order number
    PARAMETERS: p_path TYPE string DEFAULT 'C:\SchedulerInterface-OutboundTextFile\' MODIF ID a,
                p_actual AS CHECKBOX MODIF ID a.                  " Transfer Actual
    SELECTION-SCREEN END OF BLOCK b1.
    SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-t02.
    PARAMETERS : p_werks2 LIKE caufvd-werks MODIF ID b,   " Plant   "OBLIGATORY
                 p_path2 TYPE string DEFAULT 'C:\SchedulerInterface-InboundTextFile\' MODIF ID b,
                 p_path3 TYPE string DEFAULT 'C:\SchedulerInterface-InboundTextFile\' MODIF ID b,
                 p_sessio TYPE apqi-groupid MODIF ID b.   " BDC Session
    SELECTION-SCREEN END OF BLOCK b2.
    AT SELECTION-SCREEN OUTPUT.
      IF p_outb EQ 'X'.   " Outbound --> Hide inbound
        LOOP AT SCREEN.
          "IF screen-name = '%BT02011_BLOCK_1000'.
          IF screen-group2 = 'BLK'.
            screen-active = 1.
            MODIFY SCREEN.
          ENDIF.
          IF screen-group1 = 'A'.
            screen-active = 1.
            MODIFY SCREEN.
          ENDIF.
          IF screen-group1 = 'B'.
            screen-active = 0.
            MODIFY SCREEN.
          ENDIF.
        ENDLOOP.
      ELSE.
        LOOP AT SCREEN.
          "IF screen-name = '%BT01004_BLOCK_1000'.
          IF screen-group3 = 'BLK'.
            screen-active = 1.
            MODIFY SCREEN.
          ENDIF.
          IF screen-group1 = 'A'.
            screen-active = 0.
            MODIFY SCREEN.
          ENDIF.
          IF screen-group1 = 'B'.
            screen-active = 1.
            MODIFY SCREEN.
          ENDIF.
        ENDLOOP.
      ENDIF.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path2.
      CALL FUNCTION 'WS_FILENAME_GET'
        EXPORTING
          def_path         = 'C:\SchedulerInterface-InboundTextFile\'
          mask             = ',Text Files,.txt,All files,.*.'
        IMPORTING
          filename         = p_path2
        EXCEPTIONS
          inv_winsys       = 1
          no_batch         = 2
          selection_cancel = 3
          selection_error  = 4
          OTHERS           = 5.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path3.
      CALL FUNCTION 'WS_FILENAME_GET'
        EXPORTING
          def_path         = 'C:\SchedulerInterface-InboundTextFile\'
          mask             = ',Text Files,.txt,All files,.*.'
        IMPORTING
          filename         = p_path3
        EXCEPTIONS
          inv_winsys       = 1
          no_batch         = 2
          selection_cancel = 3
          selection_error  = 4
          OTHERS           = 5.
    TOP-OF-PAGE.
    START-OF-SELECTION.
    Regards
    Wiboon

  • How to disable a default selection checkbox in the tableview

    Hi All,
             How to disable a default selection checkbox in the tableview ???
    I have  a tableview  with a iterator class mentioned on the iterator attribute of the table view. Table is a MULTISELECT tableview . Is it possible to disable or make it invisible a particular row selection check box?.
    For my scenario I have Currency values on all the columns and I want to do a sub total overall total for all the price column fields in the last row of that table. I archived this functionality using Iterator class method. But I don't want the user to delete that last row in any case.
    Thanks for your help in advance.
    Thanks,
    Greetson

    Hi,
      You can NOT disable the "Checkbox" of particular row using HTMLB. I had the same requirement. I achieved using <b>2 Tableviews</b>, one after another. 1st tableview will show all the rows and 2nd Tableview(without Table Header) and without any row. The <b>total</b> will be displayed as <b>Column title</b> of 2nd Tableview.
    Here is the code of 2nd tableview which we used to display the Total:
              <htmlb:tableView id                  = "tv2"
                               headerVisible       = "false"
                               keyColumn           = "appid"
                               footerVisible       = "false"
                               selectionMode       = "SINGLESELECT"
                               design              = "ALTERNATING"
                               fillUpEmptyRows     = "false"
                               visibleRowCount     = "0"
                               width               = "100%"
                               table               = "<%= tot_header %>" >
                <htmlb:tableViewColumns>
                  <htmlb:tableViewColumn columnName = "empno"
                                         title      = "Total"
                                         width      = "50"
                                         type       = "TEXT" >
                  </htmlb:tableViewColumn>
                  <htmlb:tableViewColumn columnName = "ename"
                                         title      = "  *      "
                                         width      = "90"
                                         type       = "TEXT" >
                  </htmlb:tableViewColumn>
                  <htmlb:tableViewColumn columnName = "appamount"
                                         title      = "   <%= tot_appamt %> "
                                         width      = "60" >
                  </htmlb:tableViewColumn>
                  <htmlb:tableViewColumn columnName = "ugjr_amt"
                                         width      = "60"
                                         title      = "<%= tot_ugjr %>" >
                  </htmlb:tableViewColumn>
                  <htmlb:tableViewColumn columnName = "apprvd"
                                         width      = "50"
                                         title      = "*" >
                  </htmlb:tableViewColumn>
                </htmlb:tableViewColumns>
              </htmlb:tableView>
    Hope this will help you.
    <b>Note: Reward each useful post.</b>
    Raja T
    Message was edited by:
            Raja T

  • Inserting multiple selection from checkbox in to one column of the database

    Hi,
    how to insert multiple selection from checkbox into one column of the database.(I select array of values from checkbox ,then how to insert tat array of values iinto single column name).
    Anyone can u reply me
    Thanx

    hhhmmm.... is this what you mean?
    lets say you hava a checkbox1 with values value1, value2, value3 and you selected all there of them? then you want then to be stored in the database in one column?
    now the question is:
    Is it going to be one column one row?
    datafield
    value1,value2,value3
    Or one column multiple row?
    datafield
    value1
    value2
    value3
    Which is it?

  • Checkboxes:check the dish in one table-it checks off ingredients in another

    If you select a dish from a table of recipes (via checkbox) can you make it select all the ingredients for that dish from another table, your master ingredients list?
    I think it has to do with Boolean true/false, but checkboxes seems weird to me...they dont act like normal formula cells.....
    This would be really helpful for shopping/meal planning.........thanks

    Create a new table .
    In cell A1 grab the name of the selected dish
    In column B insert formulas grabbing the required ingredients.
    These formula would use the function VLOOKUP to extract the ingredients required for the dish whose name is in $A$1.
    I'm not sure that checkboxes are the good tool to select the dish because it's easy to have several boxes checked in a single column.
    I feel that using a popup menu would be a better soluce.
    If you really want to use checkboxes, it would be good practice to create a table with a single cell containing a formula displaying an alert if more than one box is checked.
    Yvan KOENIG (VALLAURIS, France) vendredi 5 mars 2010 22:02:42

  • How to use a SelectAll box / checkbox to select multiple checkboxes!!

    I have a question regarding checkboxes.
    My jsp page has the following layout generated dynamically based on a drop down selection box.
    ID State Initiated Released Locked
    US Initiated X
    Arg Released X X
    Ger Released X X
    Ita Locked X X X
    The Initated, Released & Locked columns are checkboxes. The checkboxes are enabled or disabled based on the State. This means that if the state is Initaited, the user will click the desired checkbox, while the others in the same row will be disabled, and so forth.
    Now all I want is the option of having a SelectAll button / checkbox (something like in yahoo,hotmail) for each column (Initiated,Released,Locked), which when clicked will select all the desired checkboxes under them.(which will select only those in the respective state).
    This is basically to make life easier for the user in case there are some 100 rows. Instead of selecting each individually, he can just click a single button for each column. He can then unselect whichever one he wants.
    I know this can be done using javascript. Remember that this list is not static, but dynamic. So I cannot send a fixed no. into my javascript function to iterate. Im using <nested:iterate> & <nested:checkbox> for iterating & displaying the checkboxes.
    If someone has a solution on it please do send me the code snippet.
    Thanks.

    Javascript is the only solution for something like this.
    I presume you are using struts indexed properties?
    Remember that this list is not static, but dynamic. So I cannot send a
    fixed no. into my javascript function to iterateTrue, but once your JSP is generated you know exactly how many controls you have generated using the varStatus of a iterate tag, or just looking at the size() of the list being iterated on. You can use that to generate the javascript function/call.
    Also you can use javascript without knowing exactly how many are there. You can actually discover the fields on the page.
    Hope this helps,
    evnafets

  • How to display the checkboxes in the output

    Hi,
    I need to display checkboxes in the output. Once i select the check box it should
    display additional info of that field in anothe list.
    another senario:
    I want to check all the checkboxes at a time.
    i want to uncheck all the ch-boxes at time.
    Can i have some explanation on this with some sample code.
    Thanks,
    Srik

    REPORT  ZTESTPROG5                              .
    TABLES: MARA.
    Types:begin of type_mara,
          matnr type mara-matnr,
          mtart type mara-mtart,
          meins type mara-meins,
          end of type_mara.
    Types: begin of type_mard,
           matnr type mard-matnr,
           werks type mard-werks,
           lgort type mard-lgort,
           labst type mard-labst,
           insme type mard-insme,
           end of type_mard.
    data: it_mara type table of type_mara,
          wa_mara type type_mara,
          it_mard type table of type_mard,
          wa_mard type type_mard.
    data: check value space,
          ucomm type sy-ucomm,
          lines type i.
    select-options: s_matnr for mara-matnr.
    initialization.
      MOVE: 'BT'       TO s_matnr-OPTION,
            '100-100'  TO s_matnr-LOW,
            '100-500'  TO s_matnr-HIGH.
      APPEND s_matnr.
    start-of-selection.
      set pf-status 'ZSTATUS'.
      select matnr mtart meins from mara
      into table it_mara
      where matnr in s_matnr.
    end-of-selection.
      loop at it_mara into wa_mara.
        write:/ check as checkbox, wa_mara-matnr, wa_mara-mtart,
                wa_mara-meins.
        hide wa_mara-matnr.
      endloop.
      lines = sy-linno - 1.
    at user-command.
      ucomm = sy-ucomm.
      case ucomm.
        when 'REPORT'.
          set pf-status 'ZSTATUS' excluding 'REPORT'.
          do lines times.
            read line sy-index field value check.
            if check = 'X'.
              select matnr werks lgort labst insme from mard
              into wa_mard
              where matnr = wa_mara-matnr.
                write:/ wa_mard-matnr, wa_mard-werks, wa_mard-lgort,
                        wa_mard-labst, wa_mard-insme.
              endselect.
            endif.
          enddo.
        when 'SELECTALL'.
          lines = lines + 1.
          do lines times.
            READ LINE sy-index FIELD VALUE check.
            IF check = space.
              check = 'X'.
              MODIFY LINE sy-index
                          FIELD VALUE  check.
            ENDIF.
          enddo.
        when 'DESELECT'.
          lines = lines + 1.
          do lines times.
            READ LINE sy-index FIELD VALUE check.
            IF check = 'X'.
              check = space.
              MODIFY LINE sy-index
                          FIELD VALUE check.
            ENDIF.
          enddo.
      endcase.

  • How to get the value of a checkbox in the backing bean

    How to get the valaue of a checkbox in the backing bean?

    Hi this may help you for selecting single check box
    <h:outputText value="Enabled : "/>
                              <h:selectBooleanCheckbox value="#{Bean.isEnabled}"/>                    
                              <h:commandButton value="Submit" action="#{Bean.submit}"/>
    private Boolean isEnabled;
        public Boolean getIsEnabled() {
            return isEnabled;
        public void setIsEnabled(Boolean isEnabled) {
            this.isEnabled = isEnabled;
        public String submit(){
         System.out.println(isEnabled);
            return isEnabled;
        }for selecting multiple check box
                              <h:selectManyCheckbox value="#{Bean.items}">
                                  <f:selectItem itemLabel="one" itemValue="one" />
                                  <f:selectItem itemLabel="two" itemValue="two" />
                                  <f:selectItem itemLabel="three" itemValue="three" />
                               </h:selectManyCheckbox>
                   <h:commandButton value="Submit" action="#{Bean.submit}"/>
    private List<String> items;
        public List<String> getItems() {
            return items;
        public void setItems(List<String> items) {
            this.items = items;
        public String submit(){
            System.out.println("List : " + this.items);
            return "done";
        }Hope this helps you

  • In tabular form, is there a way to select one row as the default row?

    Hi, I have a tabular form which lists the many addresses that a fisherman may have. The query is: select default_addr_flag, addr1, addr2, city, state, zip from addresses where fisher_id = :PXX_fisher_id.
    I would like to have them set the default_addr_flag = 'Y' for ONLY ONE record....so even if they have many addresses, one must be selected as the default for any correspondence.
    Are there any examples, or does anyone have a suggestion. thank you!
    karen

    Hi Karen,
    I think first of all you should get yourself a browser and add-ons that allow you to inspect the HTML DOM elements. E.g. FF/Firebug/Error Console. Once you have the required tools you will be able to see for yourself what the DOM has, and then work out what you need to do.
    Most members, including myself, at times post solutions without really trying them out as they appear to be "obvious" even when they are not.
    Taking forward from the point where you have made the default address indication a "simple checkbox" from the Report Attributes tab, if you inspect the checkbox element you will find that it is somewhat more complex and Apex has created the elements with some JS code. E.g. this is a snippet from one of my application pages.
    <td headers="IS_CUSTOMER">
    <label class="hideMeButHearMe" for="f08_0001">Is Customer</label>
    <input type="checkbox" onclick="if (this.checked) {apex.jQuery('#f08_0001').val('Y');} else {apex.jQuery('#f08_0001').val('');}" id="f08_0001_01" checked="checked" value="Y" name="f08_NOSUBMIT" autocomplete="off">
    <input type="hidden" id="f08_0001" value="Y" name="f08" autocomplete="off">
    </td>You will see that
    a.Apex has created a onclick event trigger
    b. If sets the value of Unchecked checkbox to null ("").
    c. In my page the checkbox maps to f08, you need to see which item it maps to in your page.
    d. The id of the rendered checkbox is id of hidden element + _01.
    The consequence of this is that if you define a onclick trigger in the Element attributes it overrides and suppresses Apex from inserting its own JS code!
    To be able to uncheck all checkboxes other than the one the user has currently checked you will need to do this:
    i. In the Column's Element Attributes field write onclick="doDftAddr(this);"You could name the function the way you want it, this is an example.
    ii.In the Page HTML Header write
    <script type="text/javascript">
    function doDftAddr(pThis) {
      va = pThis.id.split("_");
      var vb = va[0]+'_'+va[1];
    if (pThis.checked) {
        vy = 'input:checked[id^="'+va[0]+'_"]'
        $("["+vy+"]").attr("checked",false);
        apex.jQuery("["+vy+"]").val('N');
        apex.jQuery('['+'input:hidden[id^="'+va[0]+'"_]'+']').val('N');
        apex.jQuery('#'+pThis.id).attr("checked",true);
        apex.jQuery('#'+pThis.id).val("Y");
        apex.jQuery('#'+vb).val('Y');
       } else {
        apex.jQuery('#'+vb).val('N');
    </script>Cheers,

  • How to hide the Save Results Layout checkbox on the Create Saved Search pop

    I need to hide the Save Results Layout checkbox on the Create Saved Search popup. Can anyone tell me how to do it?
    This popup is used when the user is on a query (rendered by the af:query component) and they select click the "Save..." button. The have three options, Set as Default, Run Automatically, and Save Results Layout. I have an implementation that supports everything except saving the layout. So I need to hide that checkbox.
    Thanks,
    Mike

    For anybody else who needs to do this, here is how I did it.
    Add this to your css
    /* This hides the Save Results Layout checkbox on the Create Saved Search screen */
    span[id$='saveLayout'] {
    visibility: hidden;
    }

  • Select multiple nodes in a JTree a right click

    Hi all,
    I've a JTree and I'd like to allow the user select some nodes (one or more) right click and than show a popupMenu.
    This behavior seems not to be easy, because if I select a single node (right clicking on it) the node does not appear selected ; I need to select it left clicking and than everything works fine.
    I read some posts found in the forum and the solution seems to be :
    - attach a mouseListener to the JTree
    - get the TreePath of the node selected
    - force the selection on the node with setSelectionPath(TreePath)
    This works fine if you need to select only one node, cause if you have to select more, you simply cannot.
    I wonder a so obvious behavior is so hard to achieve.
    I hope somebody out there had made the magic.
    Any help would be appreciated.
    Flavio Palumbo

    Hi Darryl,
    I wrote the test case below.
    Using the methods you suggested it works almost fine.
    The only behavior not desired is when you select a range (shift or control), release the key an than right click ; in this case remains selected the only node you clicked on ; to select the range clicking with the right button, you have to keep pressed the key.
    Any hint would be appreciated.
    Flavio
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.MouseAdapter;
    import java.awt.event.MouseEvent;
    import javax.swing.JFrame;
    import javax.swing.JMenuItem;
    import javax.swing.JPopupMenu;
    import javax.swing.JTree;
    import javax.swing.SwingUtilities;
    import javax.swing.tree.DefaultMutableTreeNode;
    import javax.swing.tree.DefaultTreeModel;
    import javax.swing.tree.TreePath;
    public class TestTree {
        JTree jtr = null;
        public static void main(String[] args) {
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    new TestTree();
        public TestTree() {
            JFrame jf = new JFrame();
            jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            try {
                javax.swing.UIManager.setLookAndFeel(javax.swing.UIManager.getSystemLookAndFeelClassName());
                javax.swing.SwingUtilities.updateComponentTreeUI(jf);
            } catch (Throwable e) {
            jf.setPreferredSize(new java.awt.Dimension(200, 560));
            javax.swing.JScrollPane js = new javax.swing.JScrollPane();
            DefaultMutableTreeNode root = new DefaultMutableTreeNode("root");
            jtr = new JTree(root);
            jtr.addMouseListener(new TestTreeML());
            js.setViewportView(jtr);
            jf.getContentPane().add(js);
            for (int i = 0; i < 20; i++) {
                DefaultMutableTreeNode nodoFiglio = new DefaultMutableTreeNode("nodo" + i);
                ((DefaultTreeModel) jtr.getModel()).insertNodeInto(nodoFiglio, root, root.getChildCount());
            jf.pack();
            jf.setVisible(true);
        public class TestTreeML extends MouseAdapter {
            @Override
            public void mousePressed(MouseEvent e) {
            @Override
            public void mouseClicked(MouseEvent e) {
                try {
                    if (!e.getSource().equals(jtr)) {
                        return;
                    TreePath tpSel = jtr.getPathForLocation(e.getX(), e.getY());
                    if (tpSel == null) {
                        return;
                    int i = 0;
                    final DefaultMutableTreeNode node = (DefaultMutableTreeNode) tpSel.getLastPathComponent();
                    TreePath[] tpExisting = null;
                    if (e.isControlDown() || e.isShiftDown()) {
                        System.out.println("control/shift");
                        TreePath[] tpEx = jtr.getSelectionPaths();
                        tpExisting = java.util.Arrays.copyOfRange(tpEx, 0, tpEx.length + 1);
                        i = tpEx.length;
                    } else {
                        tpExisting = new TreePath[1];
                    tpExisting[i] = tpSel;
                    jtr.setSelectionPaths(tpExisting);
                    if (e.getClickCount() == 2) {
                        System.out.println("double click on " + node.getUserObject());
                    if (javax.swing.SwingUtilities.isRightMouseButton(e)) {
                        if (!e.isControlDown()) {
                            jtr.setSelectionPath(tpSel);
                        JPopupMenu menu = new JPopupMenu();
                        JMenuItem it0 = new JMenuItem("Option1");
                        it0.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent e) {
                                System.out.println("Option1 on " + node.getUserObject());
                        menu.add(it0);
                        JMenuItem it1 = new JMenuItem("Option2");
                        it1.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent e) {
                                System.out.println("Option2 on " + node.getUserObject());
                        menu.add(it1);
                        menu.show(jtr, e.getX(), e.getY());
                } catch (Throwable t) {
    }

Maybe you are looking for

  • HT1495 how can i sync aps on multiple devices on one computer

    Trying to use multiple devices on same computer but don't want the devices to have all the same aps.  how can i seperate that without having to check the aps i want each time a sync?

  • How do I get my hard drive back?

    Hello, I have a duel drive G4 and have just migrated all of my programs and files to my 2nd drive and will use this as the new start up disk. When I finished all my migration and updates I wanted to hide the old drive so it would could be accessed. I

  • Question for everyone: Swing Design Patterns

    I've used kodo for many web projects, but I am currently looking at using it for a swing application and am having a hard time figuring out the best way to use it. My original attempt used a singleton PersistenceManager for the entire application tha

  • What can replace WinHelp?

    I produce online help in WinHelp format that we attach to a graphical-user-interface (GUI) overlay on our AS/400 applications. When the application user clicks the Help button, the online help opens to either the specific topic for that window or to

  • Apple TV crashing; Mac OSX 10.5.5 / iTunes 8 issue?

    iTunes on computer says its syncing television episodes I've purchased ('transferring purchases'), but crashes every sync (even when I'm plugging in the phone!) I tried to simply cancel sync, because I could care less whether the tv shows are backed