Single Click start Edit in JTree, if component already selected

Hi all,
How would you go about making an editor start after a node has been clicked and was previously selected?
It's driving me insane. I've tried focus listeners, selection listeners, and mouse listeners, but I can never get the timing right. If someone could outline the process that would be great.

How about I post my hack...
If you extend DefaultTreeCellEditor, you can override
protected boolean canEditImmediately(EventObject event) {
To check for selection and if selected check for mouseclick 1 and left and inHitBox.

Similar Messages

  • JTree, was node already selected?

    Is there any means to see if a node was already selected when it is clicked?

    Well, don't worry, it's OK for me, I imagined this:
    In TreeSelectionListener#valueChanged: save the selected Node with SwingUtilities.invokeLater(..).
    In MouseListener#mousePressed(MouseEvent e): compare the saved node with
    tree.getClosestPathForLocation(e.getX(), e.getY()).getLastPathComponent();
    If equals --> the clicked node was already selected.
    Many thanks however to those who were trying to find a solution for me.

  • Can't single-click!

    This is an odd one. I suddenly cannot single-click on my new 15" (non-retina) MBP either with the track pad or the Logitech Marble Mouse trackball. I CAN Double/Right/two finger click, and scroll. I've restarted twice and disconnected all external USB devices including the trackball. Still no good. The mouse will move and hover does activate highlights and such, but no click.
    FYI - I do not have "tap to click" turned on. I'm using the physical button. I hate the tap to click since I always seem to click all over the place no matter how low I set the sensitivity.
    UPDATE: on latest restart I can now not use the keyboard enter key as an option for clicking. So I can't even login at startup.
    Is there still a PRAM reset command I can't try? Or something similar?
    Writing from my iPad.

    Update: on fourth restart, to run a full HD backup in prep for a worst case scenario, single-clicking started to work again. It didn't work right away and I had to use the keyboard and double-clicks to do a few things, then It seemed to start working when I got out my Bluetooth magic mouse to try that.  So I can't be certain that was the thing that fixed it. The USB trackball also works again.
    I'd still appreciate any insight into why this happened especially if it might be a hardware problem that may reoccur.

  • Single click in file open dialogs in KDE4.1

    Hi,
    In my KDE 4.1, there's something that doesn't seem right:
    If in system settings, mouse&keyboard, I set the option "Double-click to open files and folders", then it doesn't actually  listen to that setting.
    In a file open dialog, it opens a file already with a single click. This makes it very hard to select multiple files in the dialog (e.g. when opening files with kate), because if you press CTRL and click on the file, instead of just making a selection of it, it opens that 1 file and closes the file open dialog.
    Is this really the intention? How can I select multiple files that are not all below each other?
    Is it the intention that it doesn't listen to the double click setting? And is it the intention that the behaviour is inconsistent with any other desktop environment? I mean, they didn't just change something universally accepted, right?

    I mean if I just use the below script, it works.
    getURL("javascript:loadintoIframe('myframe',
    'v_vista_b5.html')");
    but if I want to control 2 iframes in one clicking, it
    doesn't work(it basically load only the second statment, and skips
    the first). I'd like to know is it possible to combine below 2
    javascript into one?
    getURL("javascript:loadintoIframe('myframe',
    'v_vista_b5.html')");
    getURL("javascript:loadintoIframe('topframe',
    'top_v_vista_b5.html')");
    thanks again.

  • Adobe Photoshop Starter edition

    How do I deselect all photos in Adobe Photoshop Starter edition in order to make a selection?

    > can you open raw file with this software if not what do you do to open them
    No, PSA SE does not have RAW support. As free software, it is intended for beginners with digital imaging, for whom RAW is not an issue.
    You probably received some software with your camera. Another options is to buy Photoshop Elements, which does have RAW support. Just one note: every make of camera [and even different models] has its own RAW format - you might want to check that your specific one is supported.

  • How to separate double click action and single click action

    in my mouse action listerner for JTable.
    i do two actions, when user doule click column header, sort the column,
    when single clicked, select all cells in this column.
    but when user double clicked, the action attached with single click also triggered.(column sorted but also selected)
    how to separate them.

    Ok, so despite my earlier suggestion being basically the only solution offered anyway on the web it appears that Lokust is correct and that the single click operation would be performed as well as the double click one. to get round this u have to implement a Timer, i'm not going to post my whole code here because most of it is irrelevent, just add this code in the correct places and it should work fine. apologies to all format junkies for not using code tags!
    import java.util.Timer;
    import java.util.TimeTask;
    public class WhateverClassName implements MouseListener {
    private Timer t;
    private boolean doubleclick;
    myTable.addMouseListener(this);
    public void mouseClicked(MouseEvent e) {
         t = new Timer();
         if (e.getClickCount() == 2){
              doubleclick = true;
         else if(e.getClickCount()==1){
              t.schedule(new MyTimerTask(),500);
    /*You need all these methods as well */
    /* (non-Javadoc)
    * @see java.awt.event.MouseListener#mouseEntered(java.awt.event.MouseEvent)
    public void mouseEntered(MouseEvent arg0) {
    /* (non-Javadoc)
    * @see java.awt.event.MouseListener#mouseExited(java.awt.event.MouseEvent)
    public void mouseExited(MouseEvent arg0) {
    /* (non-Javadoc)
    * @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent)
    public void mousePressed(MouseEvent arg0) {
    /* (non-Javadoc)
    * @see java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent)
    public void mouseReleased(MouseEvent arg0) {
    class MyTimerTask extends TimerTask{
    /* (non-Javadoc)
    * @see java.util.TimerTask#run()
         public void run() {
              if(doubleclick){
                   System.out.print("double click");
              else{
                   System.out.println("single click");
              t.cancel();
    This assumes that for it to be considered a double click user has to click twice within .5 seconds.
    Let me know if that works or not, sorry its a bit messy!

  • Ignoring single click in a JTree

    Hi,
    i crated a JTree with swing. I Also implemented an ExpandListener and a MouseListener for the tree.
    So how should i write my code, to ignore actions if mouse is just clicked once... (if i click on the handlers on the right side of the nodes, the node should not be expanded!!!!)
    Can somebody help?
    vedran

    Somehow i didn't really understood the code behind the link. I want all single clicks to be ignored. When i single click on a button than the button should not be clicked... the buttons actionevent should not be caused...
    i tried to use the code you showed me, but it did acutally nothing..
    could you explain it please?
    Vedran

  • After registering on the album starter Edition 3.0, I am getting an error message saying that windows internet explorer cannot find the website, to make sure the path or internet address is correct.  when i click ok, it all goes away, adobe and all.  Help

    I called tech support that switched me to customer care and after over half an hour on the phone, they told me to look it up in the forums.  If you have any words of wisdom, I would love to hear them now.  I guess I have to get through this registering phase to obtain the unlock code.  I am surprised at how faulty this step is.  I expected more from Adobe.
    Please help!!!  Thanks.  Lisa

    You need to update your starter edition 3.0 to a 3.2 edition. Go to www.adobe.com, click on "Downloads" then "updates", continue to look under "Product updates" and scroll down to "Photoshop Elements". Now you need to download the Adobe Photoshop Album Starter Edition 3.2. This update will automatically remove your 3.0 edition, and your photos will be accessible in the 3.2 edition. Now you can register again. Good Luck!

  • Unable to edit cells in JTable on single click of the cell.

    Hi,
    I am unable to edit a cell in JTable on single click of the cell. If I double click on the cell, I am able to edit it. Please help me.
    Thanks
    Subbu

    Thanks for all replies. Now, i am able to edit the cell on single click.

  • Single click to show selected file in editor when in "edit view"?

    Anyone know if there is an option to set single click to show selected file in editor when in "edit view"?  Instead of having to double click?

    I would also like to be able to "right-click > edit source file" in multi-track view WHEN A CLIP IS GROUPED.
    Currently, when a clip is grouped with another clip, if you select a portion of that clip to edit, then right-click it, IT WILL NOT ALLOW YOU TO "EDIT SOURCE FILE" until you have ungrouped then re-selected it, which is cumbersome.
    Not only do you have to do that, but upon returning to MT VIEW you have to remember to re-group that clip with the other clips, not being able to right-click and edit the source file of grouped clips adds unnecassary trouble and confusion to the interface, and for what?

  • JTree open folder on single click

    I have a custom tree that expands JTree and would like the folders to open/close on a single click rather than a double click (per user requirements). Should I do this with a mouse listener and based on the node do something, or is there another way? Also, how can I programatically toggle a folder node opened/closed state?
    Thanks!

    I have a custom tree that expands JTree and would
    like the folders to open/close on a single click
    rather than a double click (per user requirements).
    Should I do this with a mouse listener and based on
    the node do something, or is there another way? Also,
    how can I programatically toggle a folder node
    opened/closed state?
    Thanks!Here's one way:
    someTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
                public void valueChanged(TreeSelectionEvent e) {
                    if (!someTree.isExpanded(someTree.getSelectionModel().getLeadSelectionRow())) {
                        someTree.expandPath(e.getNewLeadSelectionPath());
            });

  • Selection on single-click with custom TreeCellEditor

    Hi,
    In a JTree with a custom treecell editor (contains checkbox, label with icon) that overrides abstractcelleditor, selection of nodes does not highlight the selection on a single click. The selection is highlighted on a double click. clicking on the checkbox works fine. any ideas? the treecellrenderer works fine. So if i remove the custom editor and only have the renderer (for checkbox, label and icon) selections are highlighted properly.
    Thanks!

    Ok, came up with a solution - it makes keyboard navigation and mouse-based multiple selection work. Here's the fixed code:
    creating the tree :
    JTree tree = new JTree( root  );
    tree.setUI( new MyTreeUI() );
    tree.setCellRenderer( new OverlayTreeCellRenderer() );
    tree.setCellEditor( new OverlayTreeCellRenderer() );
    tree.setEditable(true);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
    tree.setInvokesStopCellEditing( true );
    scrollPane.setViewportView( tree );
    add( scrollPane );the renderer / editor:
      protected static class OverlayTreeCellRenderer extends JPanel implements TreeCellRenderer, TreeCellEditor
        protected Color selBdrColor = UIManager.getColor( "Tree.selectionBorderColor" );
        protected Color selFG = UIManager.getColor( "Tree.selectionForeground" );
        protected Color selBG = UIManager.getColor( "Tree.selectionBackground" );
        protected Color txtFG = UIManager.getColor( "Tree.textForeground" );
        protected Color txtBG = UIManager.getColor( "Tree.textBackground" );
        protected JCheckBox visibleCheckBox = new JCheckBox();
        protected JLabel overlayName = new JLabel();
        protected JCheckBox showLabelCheckBox = new JCheckBox();
        protected LinkedList<CellEditorListener> listeners = new LinkedList<CellEditorListener>();
        protected final ActionListener checkBoxListener = new ActionListener() {
          public void actionPerformed ( ActionEvent ae )
            if ( stopCellEditing() )
              fireEditingStopped();
        protected final MouseListener labelListener = new MouseAdapter() {       
          public void mouseReleased ( MouseEvent e )
            if ( stopCellEditing() )
              fireEditingStopped();
         * Constructor.
        public OverlayTreeCellRenderer ()
          setLayout( new BoxLayout( this, BoxLayout.LINE_AXIS ) );
          visibleCheckBox.setOpaque( false );
          showLabelCheckBox.setOpaque( false );
          add( visibleCheckBox );
          add( overlayName );
          add( showLabelCheckBox );
          setBackground( txtBG );
          setForeground( txtFG );     
          visibleCheckBox.addActionListener( checkBoxListener );
          showLabelCheckBox.addActionListener( checkBoxListener );
          overlayName.addMouseListener( labelListener );
         * Returns the renderer
        public Component getTreeCellRendererComponent ( JTree tree, Object value,
            boolean selected, boolean expanded, boolean leaf, int row,
            boolean hasFocus )
          DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;           
          OverlayDescriptor data = (OverlayDescriptor) node.getUserObject();
          overlayName.setText( data.overlayName );
          visibleCheckBox.setSelected( data.visible );
          showLabelCheckBox.setSelected( data.label );   
          if ( selected )
            setBackground( selBG );
            setForeground( selFG );
          else
            setBackground( txtBG );
            setForeground( txtFG );
          return this;
        // ------------------------------------------------- Cell Editor
        // Returns the editor
        public Component getTreeCellEditorComponent ( JTree tree, Object value,
            boolean isSelected, boolean expanded, boolean leaf, int row )
          return getTreeCellRendererComponent( tree, value, true, expanded, leaf, row, true );
        // Implement the CellEditor methods.
        public void cancelCellEditing ()
        // Stop editing only if the user entered a valid value.
        public boolean stopCellEditing ()
          requestFocusInWindow();
          return true;
        // This method is called when editing is completed.
        // It must return the new value to be stored in the cell.
        public Object getCellEditorValue ()
          return new OverlayDescriptor( overlayName.getText(), showLabelCheckBox.isSelected(), visibleCheckBox.isSelected() );
        // Start editing when the mouse button is clicked.
        public boolean isCellEditable ( EventObject eo )
          return true;
        public boolean shouldSelectCell ( EventObject eo )
          return true;
        // Add support for listeners.
        public void addCellEditorListener ( CellEditorListener cel )
          listeners.add( cel );
        public void removeCellEditorListener ( CellEditorListener cel )
          listeners.remove( cel );
        protected void fireEditingStopped ()
          if ( listeners.size() > 0 )
            ChangeEvent ce = new ChangeEvent( this );
            for ( CellEditorListener l : listeners )
              l.editingStopped( ce );
      }subclass of BasicTreeUI:
       * Fix multiple-selection handling in BasicTreeUI which doesn't appear to work
       * when the tree has a custom editor.
      protected static class MyTreeUI extends BasicTreeUI {   
        protected boolean startEditing ( TreePath path, MouseEvent event )
           * BasicTreeUI startEditing(..) method doesn't handle multiple selection
           * well. This circumvents that for when Ctrl or Shift is held down by
           * first saving the current selection, and then restoring it after calling
           * super.startEditing(..).
          ArrayList<TreePath> selectedPaths = null;
          if ( tree.getSelectionCount() > 0 && event.isControlDown() )
            selectedPaths = new ArrayList<TreePath>( tree.getSelectionCount() + 1 );
            for ( TreePath p : tree.getSelectionPaths() )
              selectedPaths.add( p );
            if ( !tree.isPathSelected( path ) )
              selectedPaths.add( path );
            else
              selectedPaths.remove( path );
          else if ( tree.getSelectionCount() > 0 && event.isShiftDown() )
            int endRow = tree.getRowForPath( path );
            int startRow = tree.getAnchorSelectionPath() == null ? endRow : tree
                .getRowForPath( tree.getAnchorSelectionPath() );
            if ( startRow > endRow )
              int temp = endRow;
              endRow = startRow;
              startRow = temp;
            selectedPaths = new ArrayList<TreePath>( endRow - startRow + 1 );
            for ( int row = startRow; row <= endRow; row++ )
              selectedPaths.add( tree.getPathForRow( row ) );
          boolean val = super.startEditing( path, event );
          if ( selectedPaths != null )
            tree.setSelectionPaths( selectedPaths.toArray( new TreePath[0] ) );
          return val;
      };

  • Not able to view catalogs in CCM after clicking on "edit catalog"

    Hi all,
    I am not able to view a single catalog (supplier, procurement or master) in CCM after clicking on edit catalog.
    After clicking on "start" pushbutton, it is giving warning message "Error while editing Master catalog"
    Could anybody tell me, what would be the problem ??
    Thanks in advance.
    Regards,
    Vivek !!
    Edited by: vivek kulkarni on May 26, 2009 12:18 PM

    Hi Jason,
    Thanks for reply and solution.....
    but this problem is only for my user ID and not for all other user ID.
    when we tried with other user IDs, all the catalogs are in green state and working fine. For my ID I am not able to view any catalog into edit catalog screen. When I am trying to search any catalog it is giving me warning message "Error in master catalog". When checked in SLG1 I got error as "catalog (catalog name) not found".
    Is it related to any user setting or like that... as this is the issue with my individual ID.
    Please suggest.
    Thanks !
    Vivek

  • Closing the browser with a single click from form

    Hi All,
    Will u please help me anyone how to close the browser with a single click pressing exit button or closing the cross buton.
    Arif

    Always start with a search on this forum
    Solution
    Instructions:
    1. Using an html or text editor, create an html file with the following code:
    <html>
    <head>
    <script type="text/javascript">
    // Create a ref to the original method
    var windowClose = window.close;
    // Re-implement window.open
    window.close = function ()
    window.open("","_self");
    windowClose();
    </script>
    </head>
    <body onload="window.close()">
    <!-- The following text added in case users have disabled Java Scripting -->
    <!-- or if browser fails to close for some other reason. -->
    Your browser or system settings have prevented this window from closing.
    In order to ensure the highest level of security,
    please close/exit this browser session immediately.
    </body>
    </html> 2. Save the html file with the following name: close.htm
    3. Store this file on the middle tier, in a directory which has an associated virtual path configured in the HTTP Server. You can use a pre-existing path or create a new one. For example, in version 10.1.2 you could copy the html file to this directory:
    ORACLE_HOME\tools\web\html
    The above virtually maps to the following by default:
    /forms/html/
    For information on creating a virtual path for the HTTP Server, please refer to the HTTP Server Administrator's Guide.
    4. In the Forms application, choose the desired trigger where you would like to execute the closing of the browser. Remember that by executing this code, the application will be ungracefully terminated, therefore it is recommended that the following code only be entered in the Forms POST-FORM trigger.
    web.show_document ('/forms/html/close.htm','_self');
    5. Compile and run the form.
    Upon exiting the form, the web browser will call close.htm resulting in the browser closing.
    This has been successfully tested using IE7 on XP-SP3. Although this code will work with other browsers, for example FireFox 3, a configuration change in FF must be made in order for it to work correctly.
    Manual Steps Required for FireFox:
    1. Open one instance of the FireFox browser.
    2. In the address bar, enter the following and press Enter on the keyboard:
    about:config
    3. In the list presented, locate the following parameter:
    dom.allow_scripts_to_close_windows
    4. Double-click on this parameter to set its value to TRUE
    5. Exit the browser
    Edited by: BaiG on Mar 30, 2010 12:23 PM

  • How to Open new screen for single click on ALV icon.

    Hi All,
    Can any body help me regarding the below ALV requirement.
    I need to create a executable program ZPROGRAM with a table having field to store long text.The ALV report should display records according to the selection screen parameters with a icon in each record when clicked should open a new screen with present data in the field and must be able to save the entered long text.
    Can any body give me the idea after displaying the simple ALV in the output,
    How to open new screen(not the Pop-up’s) after single click on the icon,
    in that I should be able to modify & save the long text in my ZTABLE and
    able to retrieve the same text for single clicked icon record.
    which function modules/Classes/Methods can we use for this requirement.
    And how retrieve the same text for this record.
    Thanks in advance.
    Regards,
    Kalam A.

    *& Report  ZTEST_ALV
    REPORT  ZTEST_ALV.
    TYPE-POOLS slis.
    DATA: gt_fieldcat TYPE TABLE OF slis_fieldcat_alv .
    DATA: gs_layout  TYPE slis_layout_alv.
    DATA: gt_list_top_of_page TYPE slis_t_listheader.
    DATA: gt_sortinfo_alv   TYPE  slis_t_sortinfo_alv.
    DATA: gs_print_alv TYPE slis_print_alv.
    DATA: gs_grid TYPE lvc_s_glay.
    DATA: gt_event TYPE slis_t_event.
    DATA: gs_event TYPE slis_alv_event.
    DATA: BEGIN OF GT_DISPLAY OCCURS 100.
       INCLUDE STRUCTURE MARA.
       DATA: BOX.
    DATA: END OF GT_DISPLAY.
    START-OF-SELECTION.
    SELECT * FROM MARA UP TO 50 ROWS
      INTO CORRESPONDING FIELDS OF TABLE GT_DISPLAY.
    End-of-Selection.
      PERFORM build_alv.
      PERFORM display_screen .
    FORM build_alv .
      DATA: ls_fieldcat LIKE LINE OF gt_fieldcat.
      DATA: ls_top TYPE LINE OF slis_t_listheader.
      DATA: ls_sort TYPE slis_sortinfo_alv.
      CLEAR: ls_fieldcat, gt_fieldcat[], ls_top,gt_list_top_of_page[],
             ls_sort,gs_grid,gs_print_alv,gt_sortinfo_alv[].
    *&-----gs_layout definition.
    gs_layout-zebra = 'X'.
    gs_layout-detail_popup = 'X'.          "ÊÇ·ñµ¯³öÏêϸÐÅÏ¢´°¿Ú
    gs_layout-f2code = '&ETA'.             "ÉèÖô¥·¢µ¯³öÏêϸÐÅÏ¢´°¿ÚµÄ¹¦ÄÜÂë,ÕâÀïÊÇË«»÷
      gs_layout-no_vline = ' '.              "ÉèÖÃÁмä¸ôÏß
      gs_layout-colwidth_optimize = 'X'.     "ÓÅ»¯Áпí
      gs_layout-detail_initial_lines = 'X'.
    gs_layout-coltab_fieldname = 'LINE_COLOR'. "Line_colorΪgt_displayµÄÒ»¸ö×Ö¶Î,¾ßÌåÑÕÉ«ÉèÖüûÏÂÃæ˵Ã÷.
      gs_layout-hotspot_fieldname = 'MATNR'.
    gs_layout-detail_titlebar = 'ÏêϸÄÚÈÝ'. "ÉèÖõ¯³ö´°¿ÚµÄ±êÌâÀ¸
    gs_layout-group_change_edit = 'X'.
    *&-----gs_grid definition.
      gs_grid-top_p_only = 'X'.
    *&-----gs_print_alv definition.
      gs_print_alv-prnt_title = 'X'.
      gs_print_alv-prnt_info = 'X'.
    *&-----gt_sortinfo_alv definition. С¼Æ
      ls_sort-fieldname = 'MTART'.
      ls_sort-tabname =  'GT_DISPLAY'.
      ls_sort-subtot = 'X'.
      ls_sort-spos      = 1.
      ls_sort-up        = 'X'.
    ls_sort-group = 'UL'.
      APPEND ls_sort TO gt_sortinfo_alv.
      ls_sort-fieldname = 'AENAM'.
      ls_sort-tabname =  'GT_DISPLAY'.
      ls_sort-subtot = 'X'.
      ls_sort-spos      = 1.
      ls_sort-up        = 'X'.
    ls_sort-group = 'UL'.
      APPEND ls_sort TO gt_sortinfo_alv.
    *&-----slis_t_listheader definition. title.
      CLEAR  ls_top.
      ls_top-key  = 'µ±Ç°ÈÕÆÚ:'.
      ls_top-typ  = 'S'.  " H = Header, S = Selection, A = Action
      CONCATENATE  sy-datum0(4)   '-' sy-datum4(2) '-' sy-datum+6(2) INTO ls_top-info .
      APPEND ls_top TO gt_list_top_of_page.
      CLEAR  ls_top.
      ls_top-key  = 'title'.
      ls_top-typ  = 'S'.  " H = Header, S = Selection, A = Action
      ls_top-info = space.
      APPEND ls_top TO gt_list_top_of_page.
    *&-----gs_print_alv definition.
      gs_print_alv-prnt_title = 'X'.
      gs_print_alv-prnt_info = 'X'.
    *&-----gt_fieldcat definition.
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
       EXPORTING
         i_program_name     = sy-repid
         i_internal_tabname = 'GT_DISPLAY'
          i_structure_name = 'MARA'
          I_CLIENT_NEVER_DISPLAY = 'X'
         i_inclname         = sy-repid
       CHANGING
         ct_fieldcat        = gt_fieldcat[]
       EXCEPTIONS
         inconsistent_interface = 1
         program_error          = 2
         OTHERS                 = 3.
      ls_fieldcat-hotspot = 'X'.
      MODIFY gt_fieldcat FROM ls_fieldcat INDEX 2.
    **-1. definition with macro.
      DEFINE macro.
       col_pos = col_pos + 1.
       ls_fieldcat-tabname   = 'it_typ_data'.
        ls_fieldcat-fieldname = '&1'.
        ls_fieldcat-seltext_l =  &2.
       ls_fieldcat-col_pos   =  col_pos.
        ls_fieldcat-outputlen =  '&3'.
       ls_fieldcat-datatype  =  '&4'.
       ls_fieldcat-do_sum    =  &5.
       ls_fieldcat-edit    =   &6.
       ls_fieldcat-checkbox  =   &7.
       ls_fieldcat-key   =   &9.
       ls_fieldcat-fix_column =  &10.
       ls_fieldcat-no_out =  &11.
        ls_fieldcat-ref_fieldname = &4.    " System F4 Effect.
        ls_fieldcat-ref_tabname   =  &5.   " System F4 Effect.
        ls_fieldcat-hotspot   =   &6.
        append ls_fieldcat to gt_fieldcat.
        clear ls_fieldcat.
      END-OF-DEFINITION.
      macro matnr     'matnr'            18   'MATNR'   'MARA'  'X'.
      macro MTART     'MTART'            18      'MTART' 'MARA'  ''.
      macro  AENAM    'AENAM'            18       'MAENAM'  'MARA'   ''.
    **-2. definition one-by-one.
    CLEAR ls_fieldcat.
    ls_fieldcat-fieldname = 'MATNR'.
    ls_fieldcat-seltext_s = 'ÎïÁÏ'.
    ls_fieldcat-ref_fieldname = 'ROLLNAME'.
    ls_fieldcat-ref_tabname   =  'DD03L'.
    APPEND ls_fieldcat TO gt_fieldcat.
    ENDFORM.                    "build_alv
    FORM display_screen .
    CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
       EXPORTING
         i_list_type     = 0
       IMPORTING
         et_events       = gt_event
       EXCEPTIONS
         list_type_wrong = 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.
    READ TABLE gt_event INTO gs_event WITH KEY name = 'TOP_OF_PAGE'.
    IF sy-subrc EQ 0.
       gs_event-form = 'TOP_OF_PAGE'.
       MODIFY gt_event FROM gs_event INDEX sy-tabix.
    ENDIF.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
      I_INTERFACE_CHECK                 = ' '
      I_BYPASSING_BUFFER                = ' '
      I_BUFFER_ACTIVE                   = ' '
         i_callback_program                = sy-repid
        i_callback_pf_status_set          = 'PF_STATUS_SET '
         i_callback_user_command           = 'USER_COMMAND'
        i_callback_top_of_page            = 'TOP_OF_PAGE'
       I_CALLBACK_HTML_TOP_OF_PAGE       = 'HTML_TOP_OF_PAGE'
      I_CALLBACK_HTML_END_OF_LIST       = ' '
      I_STRUCTURE_NAME                  =
        I_BACKGROUND_ID                   = 'ALV_BACKGROUND'    "When top-of-page is initial.
      I_GRID_TITLE                      =
      I_GRID_SETTINGS                   =
         is_layout                         = gs_layout
         it_fieldcat                       = gt_fieldcat[]
      IT_EXCLUDING                      =
      IT_SPECIAL_GROUPS                 =
        it_sort                           =  gt_sortinfo_alv[]
      IT_FILTER                         =
      IS_SEL_HIDE                       =
      I_DEFAULT                         = 'X'
       I_SAVE                            = 'A'
      IS_VARIANT                        =
      IT_EVENTS                         = gt_event
      IT_EVENT_EXIT                     =
       IS_PRINT                          = gs_print_alv
      IS_REPREP_ID                      =
      I_SCREEN_START_COLUMN             = 0
      I_SCREEN_START_LINE               = 0
      I_SCREEN_END_COLUMN               = 0
      I_SCREEN_END_LINE                 = 0
      I_HTML_HEIGHT_TOP                 = 0
      I_HTML_HEIGHT_END                 = 0
      IT_ALV_GRAPHICS                   =
      IT_HYPERLINK                      =
      IT_ADD_FIELDCAT                   =
      IT_EXCEPT_QINFO                   =
      IR_SALV_FULLSCREEN_ADAPTER        =
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER           =
      ES_EXIT_CAUSED_BY_USER            =
        TABLES
          t_outtab                          = gt_display
    EXCEPTIONS
       program_error                     = 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.
    ENDFORM.                    "display_screen
    FORM user_command          USING ucomm LIKE sy-ucomm
                               selfield TYPE slis_selfield.
    Data ref1 type ref to cl_gui_alv_grid.
      CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR' "Check Box need fieldcat-checkbox, input and edit.
         IMPORTING
           E_GRID = ref1.
      CASE ucomm.
        WHEN '&IC1'. " SAP standard code for double-clicking
    READ TABLE gt_display INTO gs_display INDEX  slis_selfield-tabindex.
    CHECK sy-subrc = 0.
         CASE  selfield-fieldname  .
           WHEN 'PLNUM'.
             SET PARAMETER ID 'PAF' FIELD gs_display-plnum.
             CALL TRANSACTION 'MD12' AND SKIP FIRST SCREEN.
           WHEN  'POSNR'.
           SUBMIT  rvscd100 USING SELECTION-SCREEN '1000' WITH vbeln = gs_display-vbeln
                                                          WITH posnr = gs_display-posnr
                                                          WITH zinfo = 'X'
                                                          AND RETURN.
         ENDCASE.
       IF selfield-sel_tab_field = 'OUT_ITAB-PI_SL'. " Line detail.
           READ TABLE i_output INTO pisl_itab INDEX selfield-tabindex.
           IF sy-subrc EQ 0.
       ENDIF.
        WHEN 'CHANGE'.
         CALL METHOD ref1->check_changed_data.
         CALL METHOD ref1->refresh_table_display.
    *5´Ë´¦´úÂë×èÖ¹'REUSE_ALV_GRID_DISPLAY´´½¨ÐµÄÆÁÄ»£¬Ôì³ÉÆÁÄ»¶à²ã
         selfield-refresh = 'X'.
        WHEN 'SWITCH'.
         PERFORM switch_edit_mode.
        WHEN OTHERS.
      ENDCASE.
    ENDFORM.                    "user_command
    Add your code in user_command form.
    WHEN you click matnr ucomm eq '&IC1'.
    Message was edited by:
            Chunhai Hu

Maybe you are looking for

  • Exception in XML Parser (format problem?)

    Hi Experts, I am working on IDOC -> AS2 Configuration and the AS2 Configuration has the below structure <RecordSet>      <Row1>                    <row1 - field1>                    <row1 - field2>                    <row1 - field3>      </Row1>     

  • Can you bypass the Use Setup Cartridges on a HP Deskjet 3070

    Hi We have a Deskjet 3070 which was printing in different colours instead of black even with new black cartridges installed. So, we decided to do a factory reset by powering off and useing the OK, Cancel and On/Off power button sequence. Now it is lo

  • Using an Airport Extreme with a wireless router

    I use to have an original Airport Base station connected to a D-Link DSL504 ADSL Wired Router. All worked well. Then my basestation died so I upgraded my router to a Netgear DG834GT [108mps] ADSL wireless router. With this router I have never been ab

  • Java Icon in JDialog

    Hi all, Can some one tell me, how to remove the Java Icon from the left upper corner in the instance class of JDialog? Thanks, Genrry.

  • Relation between rebate recipient & cust on which cond record maintained

    Hi, Please may i know the relation between rebate recipient and customer on which condition record is maintained. Because I have maintained rebate recipient and customer on which record is maintained as different from each other. and when i create sa