Single Click on simple tree node

Hi Experts,
I have a problem ,please help me.
I need event is trigger on single click on node of simple tree.There is event of double click but i need on single click only.
If you have any test program please forward it also.
Ankur Garg.

i dont think for single click you can get any event in simple list... you can make hotspot on by this way single click will trigger the at line-selection event.
REPORT  ZSPDEXDET LINE-SIZE 200 line-count 19(4).
TABLES : MAST,STPO,MARA,MARC.
INCLUDE <SYMBOL>.
DATA : BEGIN OF I_BOM OCCURS 0.
        INCLUDE STRUCTURE STPOX.
DATA : END OF I_BOM.
DATA : BEGIN OF ITAB OCCURS 0,
       STUFE LIKE STPOX-STUFE,
       IDNRK LIKE STPOX-IDNRK,
       WEGXX LIKE STPOX-WEGXX, "NODE NO
       TTIDX LIKE STPOX-TTIDX, "NODE NO WITH PARENTNODE + 1
       VWEGX LIKE STPOX-VWEGX, "NODE NO OF PARENT
       MENGE LIKE STPOX-MENGE,
       SYMBOL,
       END OF ITAB.
DATA : ITAB1 LIKE ITAB OCCURS 0 WITH HEADER LINE,
       ITAB2 LIKE ITAB OCCURS 0 WITH HEADER LINE.
DATA : V_PARENTID LIKE STPOX-VWEGX,
       V_WEGXX LIKE STPOX-WEGXX,
       V_STUFE LIKE STPOX-STUFE,
       PREV_STUFE LIKE STPOX-STUFE.
DATA : V_OFFSET TYPE I VALUE 1,
       V_CONTENT TYPE I,
       TABIX LIKE SY-TABIX,
       V_TABIX LIKE SY-TABIX,
       T_TABIX LIKE SY-TABIX,
       V_SYMBOL,
       V_LINE LIKE SY-TABIX,
       T_INDEX TYPE I.
DATA :  V_PAGE LIKE SY-PAGNO,
        T_PAGE LIKE SY-PAGNO,
        V_LIN LIKE SY-LILLI.
PARAMETERS : P_MATNR LIKE MAST-MATNR,
             P_WERKS LIKE MARC-WERKS.
PERFORM BOM_EXPLODE.
ITAB1[] = ITAB[].
READ TABLE ITAB1 INDEX 1.
APPEND ITAB1 TO ITAB2.
PERFORM PRINT TABLES ITAB2.
AT LINE-SELECTION.
  V_LIN = SY-LILLI.
  T_PAGE = V_PAGE.
  PREV_STUFE = ITAB2-STUFE.
  V_STUFE = ITAB2-STUFE + 1.
  V_WEGXX = ITAB2-WEGXX.
  V_SYMBOL = ITAB2-SYMBOL.
  IF ITAB2-SYMBOL = '+'.
    ITAB2-SYMBOL = '-'.
    MODIFY ITAB2 INDEX V_TABIX.
  ELSEIF ITAB2-SYMBOL = '-'.
    ITAB2-SYMBOL = '+'.
    MODIFY ITAB2 INDEX V_TABIX.
  ENDIF.
  LOOP AT ITAB WHERE STUFE = V_STUFE AND VWEGX = V_WEGXX.
    V_TABIX = V_TABIX + 1.
    IF V_SYMBOL = '+'.
      MOVE-CORRESPONDING ITAB TO ITAB2.
      ITAB2-SYMBOL = '+'.
      INSERT ITAB2 INDEX V_TABIX.
    ELSEIF V_SYMBOL = '-'.
     IF V_TABIX GT 2.
      LOOP AT ITAB2 FROM V_TABIX WHERE STUFE = PREV_STUFE.
        T_TABIX = SY-TABIX.
        T_TABIX = T_TABIX - 1.
        EXIT.
      ENDLOOP.
       IF V_TABIX LE T_TABIX.
        DELETE ITAB2 FROM V_TABIX TO T_TABIX.
       ELSE.
        LOOP AT ITAB2 FROM V_TABIX.
*          T_TABIX = T_TABIX + 1.
          IF ITAB2-STUFE GT PREV_STUFE.
           DELETE ITAB2 INDEX SY-TABIX.
          ELSE.
            EXIT.
          ENDIF.
        ENDLOOP.
*        DELETE ITAB2 FROM V_TABIX WHERE STUFE LT V_STUFE.
       ENDIF.
       EXIT.
      ELSE.
        DELETE ITAB2 FROM V_TABIX.
        EXIT.
      ENDIF.
    ENDIF.
  ENDLOOP.
  SY-LSIND = 0.
  T_INDEX = 1.
  PERFORM PRINT TABLES ITAB2.
  SCROLL LIST INDEX T_INDEX TO PAGE T_PAGE . " LINE V_LIN .
*&      Form  BOM_EXPLODE
*       text
*  -->  p1        text
*  <--  p2        text
FORM BOM_EXPLODE .
  CALL FUNCTION 'CS_BOM_EXPL_MAT_V2'
    EXPORTING
      CAPID                 = 'PP01'
      DATUV                 = SY-DATUM
      MEHRS                 = 'X'
      MTNRV                 = P_MATNR
      WERKS                 = P_WERKS
    TABLES
      STB                   = I_BOM
    EXCEPTIONS
      ALT_NOT_FOUND         = 1
      CALL_INVALID          = 2
      MATERIAL_NOT_FOUND    = 3
      MISSING_AUTHORIZATION = 4
      NO_BOM_FOUND          = 5
      NO_PLANT_DATA         = 6
      NO_SUITABLE_BOM_FOUND = 7
      CONVERSION_ERROR      = 8
      OTHERS                = 9.
  IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
  ITAB-IDNRK = P_MATNR.
  ITAB-MENGE = '1'.
  ITAB-STUFE = '0'.
  ITAB-WEGXX = '0'.
  ITAB-TTIDX = '0'.
  ITAB-VWEGX = '-1'.
  ITAB-SYMBOL = '+'.
  APPEND ITAB.
  CLEAR ITAB.
  LOOP AT I_BOM.
    MOVE-CORRESPONDING I_BOM TO ITAB.
    APPEND ITAB.
    CLEAR ITAB.
  ENDLOOP.
ENDFORM.                    " BOM_EXPLODE
*&      Form  PRINT
*       text
*      -->P_ITAB1  text
FORM PRINT  TABLES   P_ITAB1 STRUCTURE ITAB.
  DATA : V_ID LIKE STPOX-VWEGX.
  DATA : T_LINE LIKE SY-TABIX,
         V_LINE TYPE I,
         V_HLINE TYPE I.
  DATA : PAGE TYPE I.
  DESCRIBE TABLE P_ITAB1 LINES V_LINE.
  T_LINE = V_LINE - 1.
  LOOP AT P_ITAB1.
    V_OFFSET = P_ITAB1-STUFE * 3.
    V_CONTENT = P_ITAB1-STUFE * 6.
    V_LINE = P_ITAB1-STUFE * 4.
    IF P_ITAB1-STUFE NE 0.
      V_HLINE = V_LINE + 2.
    ELSE.
      V_HLINE = 2.
    ENDIF.
*    T_INDEX = T_INDEX + 1.
    COMPUTE PAGE = SY-TABIX MOD 13.
    IF PAGE EQ 0.
      NEW-PAGE.
      V_PAGE = SY-PAGNO.
*     T_INDEX = 0.
    ENDIF.
    V_TABIX = SY-TABIX.
    IF P_ITAB1-SYMBOL = '+'.
       WRITE : /.
        WRITE AT : V_OFFSET  SYM_PLUS_FOLDER AS SYMBOL
                COLOR 4 INTENSIFIED HOTSPOT.
        WRITE : AT V_CONTENT P_ITAB1-IDNRK,P_ITAB1-MENGE.
      HIDE : P_ITAB1,V_TABIX,V_PAGE.
    ELSEIF P_ITAB1-SYMBOL = '-'.
      WRITE : /.
      WRITE AT V_OFFSET SYM_MINUS_FOLDER AS SYMBOL
                COLOR 4 INTENSIFIED HOTSPOT.
      WRITE : AT V_CONTENT P_ITAB1-IDNRK,P_ITAB1-MENGE.
      HIDE : P_ITAB1,V_TABIX,V_PAGE.
    ENDIF.
  ENDLOOP.
ENDFORM.                    " PRINT
regards
shiba dutta

Similar Messages

  • How to trigger event when double click on a tree node

    I have this code which creates new tab in a remote Java Class.
    treeView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<TreeItem<String>>()
       @Override
       public void changed(ObservableValue<? extends TreeItem<String>> observable, TreeItem<String> oldValue, TreeItem<String> newValue)
       System.out.println("Selected Text : " + newValue.getValue());
       // Create New Tab
       Tab tabdata = new Tab();
       Label tabALabel = new Label("Test");
      tabdata.setGraphic(tabALabel);
       DataStage.addNewTab(tabdata);
    Can you tell me how I can modify the code to open new tab when I double click on a tree node. In my code the tab is opened when I click once. What event handler do I need?

    import java.util.Arrays;
    import javafx.application.Application;
    import javafx.event.EventHandler;
    import javafx.stage.Stage;
    import javafx.scene.Scene;
    import javafx.scene.input.MouseEvent;
    import javafx.scene.layout.StackPane;
    import javafx.scene.control.TreeCell;
    import javafx.scene.control.TreeView;
    import javafx.scene.control.TreeItem;
    import javafx.scene.control.SelectionMode;
    import javafx.util.Callback;
    public class TreeTest extends Application {
      public static void main(String[] args) {
        launch(args);
      @Override
      public void start(Stage primaryStage) throws Exception {
        primaryStage.setTitle("TreeView Test");
        primaryStage.setScene(createScene());
        primaryStage.show();
      private Scene createScene() {
        final StackPane stackPane = new StackPane();
        final TreeView<String> treeView = new TreeView<String>();
        treeView.setRoot(createModel());
        treeView.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
        treeView.setCellFactory(new Callback<TreeView<String>, TreeCell<String>>() {
          @Override
          public TreeCell<String> call(TreeView<String> treeView) {
            return new ClickableTreeCell();
        stackPane.getChildren().add(treeView);
        return new Scene(stackPane);
      private TreeItem<String> createModel() {
        TreeItem<String> root = new TreeItem<String>("RootNode");
        TreeItem<String> packageA = new TreeItem<String>("package A");
        packageA.getChildren().addAll(
            Arrays.asList(new TreeItem<String>("A1"), new TreeItem<String>("A2"), new TreeItem<String>("A3"))
        TreeItem<String> packageB = new TreeItem<String>("package B");
        packageB.getChildren().addAll(
            Arrays.asList(new TreeItem<String>("B1"), new TreeItem<String>("B2"), new TreeItem<String>("B3"))
        root.getChildren().addAll(Arrays.asList(packageA, packageB));
        return root;
      private class ClickableTreeCell extends TreeCell<String> {
        ClickableTreeCell() {
          setOnMouseClicked(new EventHandler<MouseEvent>() {
            @Override
            public void handle(MouseEvent event) {
              // Handle double-clicks on non-empty cells:
              if (event.getClickCount()==2 && ! isEmpty()) {
                System.out.println("Mouse double-clicked on: " + getItem());
        @Override
        protected void updateItem(String item, boolean empty) {
          super.updateItem(item, empty);
          if (empty) {
            setText(null);
          } else {
            setText(item);

  • When generate automatically a JTable after a click on a tree node

    final int x[] = {0, 1, 2, 22, 0, 2, 0, 1, 0, 2};
    final int y[] = {0, 0, 0, 0, 1, 1, 2, 2, 3, 3};
    final int larg[] = {1, 1, 20, 1, 2, 21, 1, 22, 2, 22};
    final int haut[] = {1, 1, 1, 1, 1, 1, 1, 1, 22, 22};
    final int px[] = {5, 5, 85, 5, 0, 0, 0, 0, 0, 0};
    final int py[] = {2, 0, 0, 0, 2, 0, 2, 0, 94, 0};
    //****************** POSITIONNEMENT DES COMPOSANTS
    final Container conteneur = getContentPane();
    final GridBagLayout gridBg = new GridBagLayout();
    conteneur.setLayout(gridBg);
    final GridBagConstraints contrainte = new GridBagConstraints();
    contrainte.fill = contrainte.BOTH;
    //*********** JCOMBO1 **************
    borneDate1 = new JComboBox();
    Calendrier req = new Calendrier();
    String[] valCal = req.lireDansTable();
    borneDate1.addItem("");
    for (int i = 0; i<= valCal.length - 1; i++){
          borneDate1.addItem(valCal);
    contrainte.gridx = x[0];
    contrainte.gridy = y[0];
    contrainte.gridwidth = larg[0];
    contrainte.gridheight = haut[0];
    contrainte.weightx = px[0];
    contrainte.weighty = py[0];
    contrainte.insets = new Insets(1, 1, 1, 1);
    contrainte.ipadx = 20;
    gridBg.setConstraints(borneDate1, contrainte);
    conteneur.add(borneDate1);
    //*********** JCOMBO2 **************
    borneDate2 = new JComboBox();
    req = new Calendrier();
    valCal = req.lireDansTable();
    borneDate2.addItem("");
    for (int i = 0; i<= valCal.length - 1; i++){
    borneDate2.addItem(valCal[i]);
    contrainte.gridx = x[1];
    contrainte.gridy = y[1];
    contrainte.gridwidth = larg[1];
    contrainte.gridheight = haut[1];
    contrainte.weightx = px[1];
    contrainte.weighty = py[1];
    gridBg.setConstraints(borneDate2, contrainte);
    conteneur.add(borneDate2);
    //*********** JLABEL1 **************
    lbl1 = new JLabel(" Dates de S�lection.");
    contrainte.gridx = x[2];
    contrainte.gridy = y[2];
    contrainte.gridwidth = larg[2];
    contrainte.gridheight = haut[2];
    contrainte.weightx = px[2];
    contrainte.weighty = py[2];
    gridBg.setConstraints(lbl1, contrainte);
    conteneur.add(lbl1);
    //*********** BOUTON IMPRIMER **************
    btmImprimer = new JButton("IMPRIMER");
    contrainte.gridx = x[3];
    contrainte.gridy = y[3];
    contrainte.gridwidth = larg[3];
    contrainte.gridheight = haut[3];
    contrainte.weightx = px[3];
    contrainte.weighty = py[3];
    gridBg.setConstraints(btmImprimer, contrainte);
    conteneur.add(btmImprimer);
    //*********** BOUTON AUJOURD'HUI **************
    btmAujourdhui = new JButton("Ce jour");
    contrainte.gridx = x[4];
    contrainte.gridy = y[4];
    contrainte.gridwidth = larg[4];
    contrainte.gridheight = haut[4];
    contrainte.weightx = px[4];
    contrainte.weighty = py[4];
    gridBg.setConstraints(btmAujourdhui, contrainte);
    conteneur.add(btmAujourdhui);
    //*********** JLABEL 2 **************
    lbl2 = new JLabel(" Journal.");
    //lbl2.setVisible(false);
    contrainte.gridx = x[5];
    contrainte.gridy = y[5];
    contrainte.gridwidth = larg[5];
    contrainte.gridheight = haut[5];
    contrainte.weightx = px[5];
    contrainte.weighty = py[5];
    gridBg.setConstraints(lbl2, contrainte);
    conteneur.add(lbl2);
    //*********** JLABEL 3 **************
    lbl3 = new JLabel(" Adresse ");
    contrainte.gridx = x[6];
    contrainte.gridy = y[6];
    contrainte.gridwidth = larg[6];
    contrainte.gridheight = haut[6];
    contrainte.weightx = px[6];
    contrainte.weighty = py[6];
    gridBg.setConstraints(lbl3, contrainte);
    conteneur.add(lbl3);
    //*********** JTEXTFIELD **************
    txtPath = new JTextField();
    contrainte.gridx = x[7];
    contrainte.gridy = y[7];
    contrainte.gridwidth = larg[7];
    contrainte.gridheight = haut[7];
    contrainte.weightx = px[7];
    contrainte.weighty = py[7];
    gridBg.setConstraints(txtPath, contrainte);
    conteneur.add(txtPath);
    //*********** JTREE **************
    DefaultMutableTreeNode racine = new DefaultMutableTreeNode("MEDIACAST");
    //**********RECUPERER LES LIGNES ANIMATEUR*******
    parentNode = new DefaultMutableTreeNode("ANIMATEURS");
    racine.add(parentNode);
    GenererEnregistrement enregAnimateur = new GenererEnregistrement();
    String[] sEnregAnim = enregAnimateur.lireDansTable("SELECT numero_anim FROM animateur ORDER BY numero_anim", "numero_anim");
    for(int i = 0; i <= sEnregAnim.length - 1; i++){
    fils = new DefaultMutableTreeNode(sEnregAnim[i]);
    parentNode.add(fils);
    //************RECUPERER LES LIGNES COMPTE******************
    parentNode = new DefaultMutableTreeNode("COMPTES");
    racine.add(parentNode);
    GenererEnregistrement enregCompte = new GenererEnregistrement();
    String[] sEnregCompte = enregCompte.lireDansTable("SELECT id_compte FROM compte ORDER BY id_compte", "id_compte");
    for(int i = 0; i <= sEnregCompte.length - 1; i++){
    fils = new DefaultMutableTreeNode(sEnregCompte[i]);
    parentNode.add(fils);
    //************RECUPERER LES LIGNES DATE******************
    parentNode = new DefaultMutableTreeNode("DATES");
    racine.add(parentNode);
    GenererEnregistrement enregDate = new GenererEnregistrement();
    String[] sEnregDate = enregDate.lireDansTable("SELECT daty FROM calendrier ORDER BY numero_enreg", "daty");
    for(int i = 0; i <= sEnregDate.length - 1; i++){
    fils = new DefaultMutableTreeNode(sEnregDate[i]);
    parentNode.add(fils);
    //*************AFFICHAGE******************
    TreeNode root = racine;
    arbre = new JTree(root);
    JScrollPane paneTree = new JScrollPane();
    //**********EVENEMENT CLICK DROIT DANS JTREE***************
    MouseListener ml = new MouseAdapter() {
    public void mousePressed(MouseEvent e) {
    int selRow = arbre.getRowForLocation(e.getX(), e.getY());
    TreePath selPath = arbre.getPathForRow(selRow);
    if(selRow != -1) {
         if(e.getButton() == 1) {
         txtPath.setText(selPath.toString());
         //**-> CREER LE VECTEUR POUR JTable**<-
         String sPere = txtPath.getText();
         int iResComp = sPere.compareTo("[MEDIACAST, ANIMATEURS]" + arbre.getLastSelectedPathComponent().toString() + "]");
         //****ANIMATEURS***************
         switch(iResComp){
         case -49:
              String sReq = "SELECT animateur.matricule, animateur.prenom, calendrier.daty, compte.id_compte";
              sReq = sReq + " " + "FROM animateur, liaison";
              sReq = sReq + " " + "WHERE animateur.numero_anim = ? AND liaison.numero_anim = ? AND calendrier.daty = liaison.daty";
              String[] sParamIn = {
              arbre.getLastSelectedPathComponent().toString(), arbre.getLastSelectedPathComponent().toString()
              String[] sTypeParamIn = {
              "entier", "entier"
              String[] sParamOut = {
              "matricule", "prenom", "daty", "id_compte"
              GenererEnregistrement enreg = new GenererEnregistrement();
              objEnreg = enreg.retournerToutEnreg(sReq, sParamIn, sTypeParamIn, sParamOut);
              iNbEnreg = enreg.donnerNbEnreg(sReq, sParamIn, sTypeParamIn, sParamOut);
              Object[] teteTable = {
              "Matricule","Prenom","Date", "Numero Compte"
                                            data = clickTreeNode(teteTable.length, iNbEnreg, sParamOut.length, objEnreg);
              tableau = new JTable(data);
                                            //*********** JTABLE **************
              JScrollPane paneTab = new JScrollPane(tableau);
              contrainte.gridx = x[9];
              contrainte.gridy = y[9];
              contrainte.gridwidth = larg[9];
              contrainte.gridheight = haut[9];
              contrainte.weightx = px[9];
              contrainte.weighty = py[9];
              gridBg.setConstraints(paneTab, contrainte);
              conteneur.add(paneTab);
              break;
              else if(e.getButton() == 3) {
                   arbre.setSelectionPath(selPath);//Donne le focus au noeud click�
                   txtPath.setText(selPath.toString());
              //***********POUR LES NOEUDS PERES*******************************
              if(arbre.getLastSelectedPathComponent().toString() == "ANIMATEURS"){
                   System.out.println(selPath.getParentPath().toString());
              //***********POUR LES NOEUDS FILS********************************
              String sPere = txtPath.getText();
              int iResComp = sPere.compareTo("[MEDIACAST, ANIMATEURS]" + arbre.getLastSelectedPathComponent().toString() + "]");
              switch(iResComp){
                   case -49:
                        System.out.println("NOEUDS DANS ANIMATEURS:" + iResComp + " " + arbre.getLastSelectedPathComponent().toString());
                        break;
                   case 2:
                        if(arbre.getLastSelectedPathComponent().toString() != "COMPTES")
                             System.out.println("NOEUDS DANS COMPTES:" iResComp " " + arbre.getLastSelectedPathComponent().toString());
                             break;
                   case 3:
                        if(arbre.getLastSelectedPathComponent().toString() != "DATES")
                             System.out.println("NOEUDS DANS DATES:" + iResComp + " " + arbre.getLastSelectedPathComponent().toString());
                             break;
              arbre.addMouseListener(ml);
              paneTree.setViewportView(arbre);
              contrainte.gridx = x[8];
              contrainte.gridy = y[8];
              contrainte.gridwidth = larg[8];
              contrainte.gridheight = haut[8];
              contrainte.weightx = px[8];
              contrainte.weighty = py[8];
              gridBg.setConstraints(paneTree, contrainte);
              conteneur.add(paneTree);
              //Afficher la fen�tre
              ImageIcon ico = new ImageIcon("c:\\works\\mediacast\\gpao\\hlpglobe.gif");
              this.setIconImage(ico.getImage());
              //this.pack();
              this.setVisible(true);
    I want to generate automatically a table after a click on a tree node but I don't know when to procede

    Please do the following.<br><br>
    #In the location bar, type '''about:config''' and hit Enter.<br><br>
    #In the filter at the top, type: '''keyword.URL'''<br><br>
    #Double click it and remove whatever's in there and replace it with http://www.google.com/search?q= and then click OK.<br><br>
    #Close the tab
    The URL to add in "keyword.URL" becomes a link in this post, so right click it and choose "Copy Link Location" to copy it to the Windows clipboard. Then hit CTRL+V to paste it. Saves you having to type the whole thing.
    '''To reset your home page, do the following'''.<br><br>
    * Go to the site you want to set as your homepage.<br><br>
    * Click the Firefox button, go to '''Options '''| '''Options '''| '''General'''.<br><br>
    * Make sure it says "''Show My Homepage''" in the first dropdown menu.<br><br>
    * Click the button called "'''Use Current Pages'''" to set the homepage to the one you have on the screen.<br>
    N.B. Some of your plugins are out of date which exposes your system to attack. Please visit the [http://www.mozilla.com/en-US/plugincheck/ Plugins Check] page and update where necessary.
    Also, click '''Help '''| '''Check For Updates''' to update Firefox to 3.6.19

  • Click on Simple tree

    Hi Experts,
    I have a problem ,please help me.
    I need event is trigger on single click on node of simple tree.There is event of double click but i need on single click only.
    If you have any test program please forward it also.
    Ankur Garg.

    Hi,
    Please check whether the link given below is of any use,
    Reaction on "Click" on node of CL_GUI_SIMPLE_TREE
    Best Regards.
    Reward points if it is useful.

  • Single-click on a Tree not cancelable

    Hi,
    I have a component that includes a Tree, and the Tree uses a
    custom TreeItemRenderer. The render extends the default one, and
    adds a small graphic next to each Tree node's label.
    If users click the graphic, I'd like to prevent the default
    single-click behavior of the tree. For example, I'd like to prevent
    the node being selected.
    I've found that MouseEvent.CLICK is not cancelable, so
    preventDefault() has no effect.
    Is there a way to prevent the Tree from reacting to the
    single click, if the single-click is on the graphic in my item
    renderer?

    "Marc Missire" <[email protected]> wrote in
    message
    news:gap3mm$def$[email protected]..
    > Hi,
    >
    > I have a component that includes a Tree, and the Tree
    uses a custom
    > TreeItemRenderer. The render extends the default one,
    and adds a small
    > graphic
    > next to each Tree node's label.
    >
    > If users click the graphic, I'd like to prevent the
    default single-click
    > behavior on the tree. For example, I'd like to prevent
    the node being
    > selected.
    >
    > I've found that MouseEvent.CLICK is not cancelable, so
    preventDefault()
    > has no
    > effect.
    >
    > Is there a way to prevent the Tree from reacting to the
    single click, if
    > the
    > single-click is on the graphic in my item renderer?
    Setting mouseChildren to false on the image might work.
    HTH;
    Amy

  • Handling  single click in alv tree

    Hello Friends,
    Is there an event triggered,for single click on an alv tree.
    regards
    kaushik

    hi ,
    it_fieldcat-hotspot = 'X'.
    regards,
    venkat.
    Edited by: venkat  appikonda on Mar 13, 2008 8:11 PM
    Edited by: venkat  appikonda on Mar 13, 2008 8:12 PM

  • How to trigger an ActionListener in different class on click of a tree node

    Hi guyz,
    There are three panels inside my main Frame
    -->TopPanel,MiddlePanel and BottomPanel. I have a tree structure inside a panel. This panel along with couple more panels is in MiddlePanel. My main class is "mainClass.java". Inside that i have an actionListener for a specific button. I need to trigger that actionListener when i click one of the tree nodes in the panel i specified before. The problem is that my MiddlePanel is itself a different ".java" file which is being called in my "mainClass" when a specific button is clicked. There are different buttons in my "mainClass" file and for each one i am creating different MiddlePanels depending on the buttons clicked.
    So, if i click the tree node, i need to remove the MiddlePanel and recreate the MiddlePanel(One that will be created when a different button in the mainClass file is clicked). i.e., i need to trigger the actionListener for that corresponding button. Is there a way to do it?

    use this code to call different panel by selecting tree node.....ok
    import javax.swing.*;
    import javax.swing.tree.*;
    import java.awt.*;
    import java.sql.SQLException;
    import javax.swing.event.*;
    class MainTree extends JFrame
    private static final long serialVersionUID = 1L;
         CardLayout cl = new CardLayout();
         JPanel panel = new JPanel(cl);
    public MainTree() throws Exception
    JPanel blankPanel = new JPanel();
    blankPanel.setBorder(BorderFactory.createTitledBorder("Blank Panel"));
    panel.add(blankPanel,"0");
    panel.add(blankPanel,BorderLayout.CENTER);
         panel.setPreferredSize(new Dimension(800, 100));
         setSize(1000, 700);
    setLocationRelativeTo(null);
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    // getContentPane().setLayout(new GridLayout(1,2));
    getContentPane().setLayout(new BorderLayout());
    ConfigTree test = new ConfigTree();
    DefaultMutableTreeNode mainTree = (DefaultMutableTreeNode)test.buildTree();
    JTree tree = new JTree(mainTree);
    tree.setCellRenderer(new DefaultTreeCellRenderer(){
    private static final long serialVersionUID = 1L;
         public Component getTreeCellRendererComponent(JTree tree,Object value,
    boolean sel,boolean expanded,boolean leaf,int row,boolean hasFocus){
    JLabel lbl = (JLabel)super.getTreeCellRendererComponent(tree,value,sel,expanded,leaf,row,hasFocus);
    NodeWithID node = (NodeWithID)((DefaultMutableTreeNode)value).getUserObject();
    if(node.icon != null)lbl.setIcon(node.icon);
    return lbl;
    getContentPane().add(new JScrollPane(tree));
    loadCardPanels((DefaultMutableTreeNode)((DefaultTreeModel)tree.getModel()).getRoot());
    getContentPane().add(panel,BorderLayout.EAST);
         getContentPane().add(blankPanel,BorderLayout.WEST);
    // getContentPane().add(panel);
    tree.addTreeSelectionListener(new TreeSelectionListener(){
    public void valueChanged(TreeSelectionEvent tse){
    NodeWithID node =(NodeWithID)((DefaultMutableTreeNode)((TreePath)tse.getPath())
    .getLastPathComponent()).getUserObject();
    if(node.nodePanel != null)
    String cardLayoutID = node.ID;
    cl.show(panel,cardLayoutID);
    cl.show(panel,"0");
    public void loadCardPanels(DefaultMutableTreeNode dmtn)
    for(int x = 0; x < dmtn.getChildCount(); x++)
    if(((DefaultMutableTreeNode)dmtn.getChildAt(x)).isLeaf() == false)
    loadCardPanels((DefaultMutableTreeNode)dmtn.getChildAt(x));
    NodeWithID node = (NodeWithID)((DefaultMutableTreeNode)dmtn.getChildAt(x)).getUserObject();
    if(node.nodePanel != null)
    String cardLayoutID = node.ID;
    panel.add(cardLayoutID,node.nodePanel);
    public static void main(String[] args) throws Exception{new MainTree().setVisible(true);}
    class ConfigTree
    public Object buildTree() throws Exception
    NodeWithID n0 = new NodeWithID("HelpDesk","");
    NodeWithID n1 = new NodeWithID("Administrator",n0.nodeName);
    NodeWithID n2 = new NodeWithID("Report Form",n1.nodeName,new Tree().getContentPane());
    NodeWithID n3 = new NodeWithID("Create User",n2.nodeName,new JPanel());
    NodeWithID n4 = new NodeWithID("Unlock User",n2.nodeName,new unlockui().getContentPane());
    NodeWithID n5 = new NodeWithID("List User",n2.nodeName,new JPanel());
    NodeWithID n6 = new NodeWithID("Assign Role",n2.nodeName,new AssignRole());
    NodeWithID n9 = new NodeWithID("Operator",n1.nodeName,new JPanel());
    NodeWithID n10 = new NodeWithID("Create Ticket",n9.nodeName,new JPanel());
    NodeWithID n11 = new NodeWithID("My Ticket",n9.nodeName,new JPanel());
    NodeWithID n12 = new NodeWithID("All Ticket",n9.nodeName,new JPanel());
    NodeWithID n13 = new NodeWithID("Event Viewer",n1.nodeName,new JPanel());
    DefaultMutableTreeNode top = new DefaultMutableTreeNode(n0);
    DefaultMutableTreeNode branch1 = new DefaultMutableTreeNode(n1);
    top.add(branch1);
    DefaultMutableTreeNode node1_b1 = new DefaultMutableTreeNode(n2);
    DefaultMutableTreeNode n1_node1_b1 = new DefaultMutableTreeNode(n3);
    DefaultMutableTreeNode n2_node1_b1 = new DefaultMutableTreeNode(n4);
    DefaultMutableTreeNode n3_node1_b1 = new DefaultMutableTreeNode(n5);
    DefaultMutableTreeNode n4_node1_b1 = new DefaultMutableTreeNode(n6);
    branch1.add(node1_b1);
    branch1.add(n1_node1_b1);
    branch1.add(n2_node1_b1);
    branch1.add(n3_node1_b1);
    branch1.add(n4_node1_b1);
    DefaultMutableTreeNode node4_b1 = new DefaultMutableTreeNode(n9);
    DefaultMutableTreeNode n1_node4_b1 = new DefaultMutableTreeNode(n10);
    DefaultMutableTreeNode n2_node4_b1 = new DefaultMutableTreeNode(n11);
    DefaultMutableTreeNode n3_node4_b1 = new DefaultMutableTreeNode(n12);
    node4_b1.add(n1_node4_b1);
    node4_b1.add(n2_node4_b1);
    node4_b1.add(n3_node4_b1);
    DefaultMutableTreeNode node5_b1 = new DefaultMutableTreeNode(n13);
    branch1.add(node1_b1);
    branch1.add(node4_b1);
    branch1.add(node5_b1);
    return top;
    class NodeWithID
    String nodeName;
    String ID;
    JPanel nodePanel;
    ImageIcon icon;
    public NodeWithID(String nn,String parentName)
    nodeName = nn;
    ID = parentName+" - "+nodeName;
    public NodeWithID(String nn,String parentName,Container container)
    this(nn,parentName);
    nodePanel = (JPanel) container;
    nodePanel.setBorder(BorderFactory.createTitledBorder(ID + " Panel"));
    public NodeWithID(String nn,String parentName,JPanel p, ImageIcon i)
    this(nn,parentName,p);
    icon = i;
    public String toString(){return nodeName;}
    }

  • How to find the coordinates of a mouse click in a Tree node ?

    Hello
    I have a JTree that have few nodes. The nodes contain an icon and a label (using custom cell renderer) and I want to receive right clicks on the icon and show a popup menu.
    The problem is I can only get the right click on the whole tree node, not only the icon.
    I tried two approaches:
    1. register the mouse listener directly with the icon in the cell renderer. That doesnt work since the events received by the tree node do not propagate to its sub-components.
    2. Register the event with the JTree itself and then try to find which part of the tree node was clicked (see if it was within the coordinates of the icon).
    But I cant get the node's coordinates or width.
    I tried using SwingUtilities.convertPoint or SwingUtilities.ConvertMouseEvent but it just doesnt work with DefaultMutableTreeNode.
    Any ideas how to do it ?

    user11973359 wrote:
    1. register the mouse listener directly with the icon in the cell renderer. That doesnt work since the events received by the tree node do not propagate to its sub-components.No, it doesn't work because a renderer isn't added to any component hierarchy. It isn't in any way a 'sub-component'.
    Read about editor and renderer concepts in the Oracle tutorial on How to Use Tables.
    user11973359 wrote:
    2. Register the event with the JTree itself and then try to find which part of the tree node was clicked (see if it was within the coordinates of the icon).
    But I cant get the node's coordinates or width.<tt>getPathForLocation(...) </tt>in conjunction with<tt> getPathBounds(...)</tt>.
    db

  • Context Menu on the right click of af:tree node

    Hi Experts,
    I am using drag and drop functionality in af:tree.In that i used one tree for drag source and another one tree for drop target,and it is working as expected.
    Now I want to bring one additional option in the context menu of the target tree node that is ,when i right click on any of the target tree node in addition to the default menu options like "Collapse","Expand" i want to add one more option .For this i added "contextMenu" facet after the "nodeStamp" facet inside the tree.
    *<f:facet name="contextMenu">*
    *<af:popup id="p1">*
    *<af:menu text="Delete" id="m1">*
    *<af:commandMenuItem text="Delete" id="cmi1"*
    *action="#{myWorkflow.deleteWorkflowNode}"/>*
    *</af:menu>*
    *</af:popup>*
    *</f:facet*>
    Now the problem is : before using drag and drop the context menu workes without any problem .But after using drag and drop the context menu is not popped up.
    can anybody help me to resolve this?
    Thanks,
    Priya.

    Hi Frank,
    1. I am using JDeveloper 11.1.1.3 version
    2. Drop target tree is having the context menu.
    3. Yes . In Drop event am calling a backing bean method with return type DnDAction and i return the value as DnDAction.MOVE to reflect the changes in the database table to the target tree.
    Regards,
    Priya.

  • Displaying data in tableview on click of a tree node

    Hi,
    I am new to BSP. I created a tree structure having the tablenames as tree nodes, and now if I click on a node I want to display corresponding table data in a tableview. How can I acheive this....??
    Thanks in advance,
    Ravindra.

    Hi Ravindra,
    You can achieve this by reading the node clicked OnInput Processing and You can assign name of your table in "onNodeClick" attribute .
    then onInputprocessing you can read the name of your table from
    "event->server_event" .
    Check this sample code .
    ****************OnLayout*******************************
    <htmlb:content design="design2003">
      <htmlb:page title = " ">
        <htmlb:form>
            <htmlb:tree     id          = "myTree1"
                             title       = "Tree"
                             tooltip     = "Tooltip for myTree1">
                <htmlb:treeNode id="NODE1" text="TABLE1" isOpen="true" onNodeClick="TABLE1">
                  </htmlb:treeNode>
                  <htmlb:treeNode id="NODE2" text="TABLE2" isOpen="true" onNodeClick="TABLE2">
                 </htmlb:treeNode>
                    <htmlb:treeNode id="NODE3" text="TABLE3" onNodeClick="TABLE3"/>
                    <htmlb:treeNode id="NODE4" text="TABLE4"onNodeClick="TABLE4" />              
                  <htmlb:treeNode id="NODE5" text="TABLE5" isOpen="false" onNodeClick="TABLE5">
                  </htmlb:treeNode>
                    <htmlb:treeNode id="NODE6" text="TABLE6" onNodeClick="TABLE6"/>
            </htmlb:tree>
        </htmlb:form>
      </htmlb:page>
    </htmlb:content>
    *****************OnInputProcessing****************
    CLASS CL_HTMLB_MANAGER DEFINITION LOAD.
    Data: TABLE_NAME type STRING.
    Optional: test that this is an event from HTMLB library.
    IF event_id = CL_HTMLB_MANAGER=>EVENT_ID.
    Scenario 1: Read event from manager.
      DATA: event TYPE REF TO CL_HTMLB_EVENT.
      event = CL_HTMLB_MANAGER=>get_event( runtime->server->request ).
      IF event IS NOT INITIAL AND event->name = 'tree'.
        DATA: tree_event TYPE REF TO CL_HTMLB_EVENT_TREE.
        tree_event ?= event.
       TABLE_NAME = event->server_event.
      ENDIF.
    ENDIF.
    Check examples given in "SBSPEXT_HTMLB" bsp application.
    I hope this will help.
    Regards,
    Monica

  • Help for Activating Editing Mode on F2 Keyboard Click for a Tree Node

    I have a Jtree with several Nodes on the Left Pane. On the Right Pane I have a nodes corresponding Screen with many properties. There is a way to change the Node Name by editing the Name Field property on the Right.
    I want to Edit the tree Node name by Clicking F2 on the selected Node, Get it in the Editable Mode, Change the name and press enter. How Do I activate this editable Mode on Click of Keyboard F2 Button.

    tree.setEditable( true );

  • How to display a search(query) on a report clicking on a tree node to open

    I need to know how can I do with that when I press on the link(on a tree node(leaf)), open on the other region in the same page a classic or interactive report with my results(passed by parameter, example: ID).
    One example are present on web site posted below:
    http://apex.oracle.com/pls/apex/f?p=36648:34:1599336964673301::NO:::
    I have tried this to composite my tree:
    select case when connect_by_isleaf = 1 then 0 when level = 1 then 1 else -1 end as status, level, "NAME" as title, null as icon, "ID" as value, null as tooltip, decode(level, 1, 'f?p=&APP_ID.:106:'||:APP_SESSION||'::::P106_MAQ_ID:'||ID, 2,'f?p=&APP_ID.:106:'||:APP_SESSION||'::::::::P106_MAQ_ID:'||(ID-1000), 3,'f?p=&APP_ID.:104:'||:APP_SESSION||'::::P106_MAQ_ID:'||(ID-10000), 4,'f?p=&APP_ID.:105:'||:APP_SESSION||'::::P106_MAQ_ID:'||(ID-100000)) as link from "#OWNER#"."V_TREE1" start with "PID" is null connect by prior "ID" = "PID" order siblings by "NAME"
    But the parameter passed dont do with the report change your view to the one row with ID passed. I need to obtain the same results showed on website posted above.
    I obtained success on action to redirect to other page with Form with Report to edit, but dont to show. And i want to show and the same page.
    below the code that i obtained to redirect:
    select case when connect_by_isleaf = 1 then 0 when level = 1 then 1 else -1 end as status, level, "NAME" as title, null as icon, "ID" as value, null as tooltip, decode(level, 1, 'f?p=&APP_ID.:102:'||:APP_SESSION||'::::P102_MAQ_ID:'||ID, 2,'f?p=&APP_ID.:103:'||:APP_SESSION||'::::P103_SRV_ID:'||(ID-1000), 3,'f?p=&APP_ID.:104:'||:APP_SESSION||'::::P104_INS_ID:'||(ID-10000), 4,'f?p=&APP_ID.:105:'||:APP_SESSION||'::::P105_SIS_ID:'||(ID-100000)) as link from "#OWNER#"."V_TREE1" start with "PID" is null connect by prior "ID" = "PID" order siblings by "NAME"
    Thank you so much for your help.

    Muhammad,
    you can add a user parameter (p_count), which get the default value value 1 for example. Then add a field (with some source of type character like desname) for your footer with a format trigger like
    if :p_count=1 then
         srw.set_field_char(0,'Office Copy');
    elsif :p_count=2 then
         srw.set_field_char(0,'Shop Copy');
    else
         srw.set_field_char(0,'Account Dept Copy');
    end;
    return true;
    Or you build 3 boilerplates with format triggers like
    if :p_count=1 then return true; else return false; end if; for "Office Copy" .....
    In the After Report Trigger start the Report with same paramters using a higher value for p_count as parameter. If p_count=3, do nothing in the trigger.
    Regards
    Rainer

  • On right click, the focus is not set on tree node.

    Dear members,
    I have a tree and a database block, when i right click on a tree node, the focus is not set on the node.
    If I first click on the node and then right click on selected node it populate the database block.
    But I want to populate the datablock on right click.
    how to implement it?
    Regards:

    No body ever encountered this problem?
    Any advice would be appreciated.
    Thanks

  • Right click tree node

    Hello all,
    I need to process right click on the tree node. I can get the node and process the action well. But the problem is that the selected node doesn't have a gray box (selection indicator) like when I left click it.
    Please help me with this,
    Thanks,
    Fantabk

    Dear Siva,
    You can follow the following steps:-
    - Create local class (eg:- lcl_screen_handler) as handler class.
    - Define and implement methods handle_node_context_menu_req and handle_node_context_menu_sel for handling right click.
    - In Method handle_node_context_menu_req use CALL METHOD menu->add_function for adding entries to context menu.
    - In Method handle_node_context_menu_sel based on node_key and fcode handle logic for right click.
    - Define event handler (eg:- grc_event_handler     TYPE REF TO lcl_screen_handler) to handle events for right click on tree.
    - After creating Tree, specify events that are to be handled and assign them to tree instance
    eg:- lwa_event-eventid = cl_simple_tree_model=>eventid_node_double_click.
          lwa_event-appl_event = ' '.   "system event, does not trigger PAI
          APPEND lwa_event TO lit_event. (where, lit_event TYPE cntl_simple_events)
    - Also, register PAI for context menu as follows:-
    Process PAI if context menu select event occurs
      CALL METHOD grc_tree->set_ctx_menu_select_event_appl (where grc_tree is Tree instance)
        EXPORTING
          appl_event = 'X'.
    - Register Tree events as follows:-
    CALL METHOD grc_tree->set_registered_events
        EXPORTING
          events                    = lit_event ....
    - Create event handler instance for tree
      CREATE OBJECT grc_event_handler. (where, grc_event_handler is already declared on top)
    - Set event handler method to handle various events on tree node
    eg:-  SET HANDLER grc_event_handler->handle_node_double_click FOR grc_tree.
            SET HANDLER grc_event_handler->handle_node_context_menu_req FOR grc_tree.
            SET HANDLER grc_event_handler->handle_node_context_menu_sel FOR grc_tree.
    The events should be handled now. I have followed this approach and it worked for me.
    Regards,
    Ashish

  • JSF tree view GUI component and tree node actions

    Hi,
    I am new in using JSF and have a problem with my simple test application.
    The application contains a tree view control with one static tree node and a separate text area. Clicking on the tree node shall fill the text area with the string 'hello'. Seems to be very simple, but it doesn't work.
    What did I do?
    First of all I use the Sun Java Studio Creator 2.
    By double clicking on the tree node in the design window of the IDE a method called treeNode1_action() was created. I also added the String text to the session bean. treeNode1_Action() does not more than setting text='hello' ( getSessionBean().setText('hello'); ).
    The jsp file contains the line
    <ui:textArea binding="#{Page1.textArea}" id="textArea" style="height: 192px; left: 360px; top: 48px; position: absolute; width: 456px" text="#{SessionBean1.text}"/>, so the text of the text area is bound to the session property 'text'.
    Running the application and clicking on the tree node does nothing except reloading the page (no 'hello' inside the text area).
    Using the debugger showed me that the bean property text is set correctly to 'hello', also after reloading the page.
    What did I do wrong?
    What do I have to do to display 'hello' in the text area?
    I would be glad for some good advice to solve my problem and looking forward for an answer.
    Regards from germany
    Matthias

    want to remove the green patch from the jsf tree componentas u said ,, it is COMPONENET so this is a pre-made creator component that u cant chnage its attributes ,,
    instead u can extract Theam.jar file and change the icons ,, u i didnt do it before ,, but u may be find what u want there,
    hope this will help
    good luck
    Mohammed

Maybe you are looking for