How to capture the data entered in a textfield in a JTable

How to capture the data entered in a textfield present in a cell of a textfield or how to add listener to this textfield

A sample of my code is:
          model = new GridDisplayTableModel(gridDisp,columnName,getRows(),getCols());
          final ComboRenderer cRenderer = new ComboRenderer();
          final TextFieldRenderer tRenderer = new TextFieldRenderer();
          combo.addItem("one");
          combo.addItem("two");
          combo.addItem("three");
          final JTextField textfield = new JTextField();
          final DefaultCellEditor cmbEditor = new DefaultCellEditor(combo);
     //     final JEnterDataCellEditor textEditor = new JEnterDataCellEditor(12);
          final DefaultCellEditor textEditor = new DefaultCellEditor(textfield);
          rm = new RowEditorModel();
          table = new JTable(model){
     public TableCellRenderer getCellRenderer(int row, int column) {
          int posx = 0;
               int posy = 0;
               TableCellRenderer renderer = null;
     for(int l=0;l<getDataVec().size();l++)
               beanObj =(Helperbean)dataVec.elementAt(l);
               posx = beanObj.getPosx();
               posy = beanObj.getPosy();
               if(row==posx && column==posy)
                         if(beanObj.getModeofDisplay() != null && beanObj.getModeofDisplay().equalsIgnoreCase("textfield"))
                              rm.addEditorForRow(row,textEditor);
                              renderer = tRenderer;
                         else if(beanObj.getModeofDisplay() != null && beanObj.getModeofDisplay().equalsIgnoreCase("combo"))
                              rm.addEditorForRow(row,cmbEditor);
                              renderer = cRenderer;
                         break;
                    renderer = super.getCellRenderer(row, column);
          //     System.out.println("getEditor"+rm.getEditor(1));
     return renderer;
public TableCellEditor getCellEditor(int row, int col) {   
     int posx = 0;
     int posy = 0;
     TableCellEditor tmpEditor = null;
for(int l=0;l<getDataVec().size();l++)
     beanObj =(Helperbean)dataVec.elementAt(l);
     posx = beanObj.getPosx();
     posy = beanObj.getPosy();
     if(row==posx && col==posy)
               if(beanObj.getModeofDisplay() != null && beanObj.getModeofDisplay().equalsIgnoreCase("textfield"))
                    System.out.println("celleditorval "+textEditor.getCellEditorValue());
                    tmpEditor = textEditor;
               else if(beanObj.getModeofDisplay() != null && beanObj.getModeofDisplay().equalsIgnoreCase("combo"))
                    tmpEditor = cmbEditor;
               break;
          tmpEditor = super.getCellEditor(row, col);
return tmpEditor;
public boolean isCellEditable(int row,int col){
     boolean isEditable = false;
     int posx = 0;
     int posy = 0;
for(int l=0;l<getDataVec().size();l++)
     beanObj =(Helperbean)dataVec.elementAt(l);
     posx = beanObj.getPosx();
     posy = beanObj.getPosy();
     if(row==posx && col==posy)
          if(beanObj.getModeofDisplay() != null )     
                    isEditable = true;     
               else
                    isEditable = false;     
               break;
     isEditable = false;
     return isEditable;
public void changeSelection(final int row, final int column, boolean toggle, boolean extend) {
     super.changeSelection(row, column, toggle, extend);
     //my attempt to avoid editCellAt from being called twice in a row
     if (getModel().isCellEditable(row, column) && !(isEditing() && getEditingRow() == row && getEditingColumn() == column))
          if (editCellAt(row, column)) {
               getEditorComponent().requestFocus();
     // Select the text when the cell starts editing
public boolean editCellAt(int row, int column) {       
     boolean result = super.editCellAt(row, column);
     final Component editor = getEditorComponent();
     if (editor != null && editor instanceof JTextField) {           
          SwingUtilities.invokeLater(new Runnable() {               
               public void run() {                   
                    ((JTextField)editor).selectAll();
          return result;
     public boolean hasFocus()
          Component editorComponent = getEditorComponent();
          // Try to install the editor
          int anchorRow = getSelectionModel().getAnchorSelectionIndex();
          int anchorColumn = getColumnModel().getSelectionModel().
          getAnchorSelectionIndex();
          if (anchorRow != -1 && anchorColumn != -1 && !isEditing())
          if ((this.getSelectedRow() == anchorRow) && (this.getSelectedColumn() == anchorColumn))
          if (!editCellAt(anchorRow, anchorColumn)) {}
          return super.hasFocus();
     public void valueChanged(ListSelectionEvent e)
          super.valueChanged(e);
          if ((this.getSelectedRow() == 2) && (this.getSelectedColumn() == 3))
               DefaultFocusManager focusManager = new DefaultFocusManager();
               focusManager.focusNextComponent(this);
               model.fireTableStructureChanged();
     

Similar Messages

  • How to capture the date and time of  a background job

    Hi experts,
    How to capture the date and time of  a background job?
    How to find whether it is runned succesfully or not?
    If it is not successful how to put error message?
    ASAP
    Thanx in advance,
    Sudha

    To Display the STATUS of the JOB which is exectued in background
      CLEAR : wa_jobsteplist.
      REFRESH : i_jobsteplist.
      WRITE:/ 'DISPLAYING JOB STATUS'.
      CALL FUNCTION 'BP_JOB_READ'
        EXPORTING
          job_read_jobcount           = w_jobcount
          job_read_jobname            = w_jobname
          job_read_opcode             = '20'
        JOB_STEP_NUMBER             =
       IMPORTING
         job_read_jobhead            = wa_jobhead
       TABLES
         job_read_steplist           = i_jobsteplist
    CHANGING
       RET                         =
       EXCEPTIONS
         invalid_opcode              = 1
         job_doesnt_exist            = 2
         job_doesnt_have_steps       = 3
         OTHERS                      = 4
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    To Display the status text as per the status type
      CASE wa_jobhead-status.
        WHEN 'S'. WRITE: / 'Scheduled'.
        WHEN 'R'. WRITE: / 'Released'.
        WHEN 'F'. WRITE: / 'Completed'.
        WHEN 'A'. WRITE: / 'Cancelled'.
        WHEN OTHERS.
      ENDCASE.

  • How to keep the data entered on a page apex

    how to keep the data entered on a page apex
    so, I've got a registration page then wish go to another page P2 and I return to this P1 without losing data

    Hi,
    As long as the registration page is within the same session, the values will remain in the session until they are specifically cleared out. This can be done by a process on a page - so check if you have a "reset page" process on P1 and, if you do, delete it. This can also be done on a branch - so check the branch that takes you to P2 and see if there is anything entered in the Clear Cache setting and, if it shows *1*, remove that. There are other ways as well, but these are most typical.
    Andy

  • How to capture the data that the user modified in SM30(Maintenance view)

    Hello experts,
    I have a new requirement wherein when the user modifies a particular record in SM30(maintenance view)
    it would also update that certain records in another table. For example, I modified the address
    of record 1 in table1 so I need to automatically update that same record in table2. Help would be greatly appreciated.
    Again, thank you guys and have a nice day!

    Hi again,
    1. But how can I capture the data that was modified
    Yes, u are right.
    We will have to use the event,
    'BEFORE SAVING'.
    2. In that,
      u must fire a select query,
       from the same table,
       for the same record.
    3. In this, u will get the OLD DATA (which was already saved),
    4. Using this,u can compare,
       (either thru LOOP, or field by field)
      to know, which field value has been changed.
    regards,
    amit m.

  • How to capture the data from a JSP form

    Hi
    I have a JSP form, My task is to capture the data from a JSP and submit to Data Base. for example I have the field like
    Enter Table name to be created in data base: The table name is to be captured by a servlet and by that table name, table should be created in the data base.
    Edited by: Reddy_Prasad on ?? ?????, ???? ?:?? ???????
    Edited by: Reddy_Prasad on ?? ?????, ???? ?:?? ???????

    Get the entered value from the jsp into servlet using request.getParameter("enteredTableName"). it will return the String,pass this table name to execute query using JDBC connection and statement objects.
    -cheers Ram

  • How to capture the data of the fields of a particular subform

    xfa.data.saveXML() saves the data of the whole form, but I need to capture the data of a particular subform  .. How do I do this...?

    declare a character type internal table.
    now move your data from it_data ( internal table with data ) into table itab.
    since you are running this report in background, you cannot save it to the desktop. Instead give any app server location
    data: itab(400) occurs 0 with header line.
    field-symbols: <fs1> type any.
    data: gv_file type rlgrap-filename default 'TEST.TXT'.
    data: gv_filepath type rlgrap-filename default <path>.
    LOOP AT it_data.
        DO 100 TIMES.
          ASSIGN COMPONENT sy-index OF STRUCTURE it_data TO <fs1>.
          IF sy-subrc = 0.
            CONCATENATE itab <fs1> INTO itab SEPARATED BY ' '.
          ELSE.
            EXIT.
          ENDIF.
        ENDDO.
        SHIFT itab LEFT DELETING LEADING ' '.
        APPEND itab.
        CLEAR itab.
      ENDLOOP.
      concatenate gv_filepath '/' gv_file into gv_file.
      OPEN DATASET gv_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
      IF sy-subrc = 0.
        LOOP AT itab.
          TRANSFER itab TO gv_file.
        ENDLOOP.
        CLOSE DATASET gv_file.
      ENDIF.

  • How to capture the data if i am using two Fiscal year variant

    Hi
    My client is required need two type financial statement one is as per company act and calender year.  Other one is company act and fiscal year.
    regarding we have maintain two fiscal year variant one is assigned to company code as per calender yr other one is assigned to Spl.Pr G/L. but how to capture the financial data from company code in case we are using two fiscal yr variant.
    Rekha

    Hi
    U cannot maintain two two fiscal year varaint for a company code in GL. As said by u maintain one fiscal year varaint for GL and the other one for FI SL. When u post FI document in GL automatically the same will flow into FI SL for the corressponding period.
    For example ur Fiscal year varant is April to March in GL
    and Callendar year in FI SL and u do a posting in April 1 (period 1) in GL then it post it to  4th period in FI SL automatically since April is the 4th period in FI SL since it uses K4 as the fiscal year variant.

  • How to capture the data input in the input box like text box  on webpage?

    I would like to know how to use the data we key in in the textbox on the webpage and write it to database using JSP

    I would like to know how to use the data we key in in
    the textbox on the webpage and write it to database
    using JSPIf you want to store it into database....you'll need that
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con = DriverManager.getConnection("jdbc:odbc:YourDSN");
    Statement stat = con.createStatement();
    String query = "INSERT INTO yourTable (Field) VALUES(TextBox value)";
    stat.executeQuery(query);
    con.close()
    Not tested but should work (depends also on your configuration)

  • How to capture the data within the given range of maximum and minimum values ? from csv files

    My requirement,
    1. Here, the user will provide the range like maximum and minimum values, based on this range, the VI should capture the data within the given range. ( from CSV file as attached )
    2. Then VI should calcluate the average value for captured data and export it to excel.
    This is my requirement can anyone help me on this.
    Many thanks in advance
    rc_cks
    Attachments:
    sample_short.csv ‏2439 KB

    Hi,
    Thanks for remnding me. I forgt to attach the VI, 
    Here I am attaching the VI, what I tried. 
    From attached CSV file, I have to find an average value for columns B,C,D,E,F,G,H,I and AJ, AK. ( data range will be defined  by user ), focused only on these columns
    Here, the scope is to calculate an average value for given data range by user as MAX and MIN data.  
    FYI:  I tried manually for two instance i.e column H & I.  As per H column one steady state values from  7500 to 10500 and similarly in I column 7875 to 10050. So, I gave these as a limit to capture and calculate the average value. But unfortunaltely, requirement has been modified as per below requirements.
    More Info on requirement: 
    --> The user will define the range of data by giving some MAXIMUM and MINIMUM values(for above mentioned columns induvidually), then VI should capture          that data range and it has to caculate the average value for that range of data. This is the task I have to complete. 
    --> I am stuck in creating a logic for data capturing for given range of MAX and MIN value from user, 
         Can anyone help me on this. 
    If my explanation is not clear, Please let me know.  
    Many thanks, help mw
    rc
    Attachments:
    VI_rc.vi ‏25 KB
    sample.zip ‏4166 KB

  • How to capture the data from JOBLOG

    Hi Experts,
    When we execute 'F110' transaction code it creates a joblog.
    I need to capture the joblog data through 'Z' program and it should display the joblog data in SO01 transaction code.
    The above process goes through when we execute 'F110' Transaction.
    So, Please help me how to solve the above issue.
    <b><REMOVED BY MODERATOR></b>
    Thanks,
    vinay.
    Message was edited by:
            Alvaro Tejada Galindo

    To capture job logs, try this:
    Get job log
      select single joblog into tbtco-joblog from tbtco
                    where jobname = <your jobname>
                      and jobcount = <your jobcount>.
      check sy-subrc = 0.
    Convert to message type
      call function 'COMMON_LOG_READ_T100'
           exporting
                client                        = sy-mandt
                logname                       = tbtco-joblog
           tables
                logtable                      = logtable
           exceptions
                logname_missing               = 1
                log_handle_error              = 2
                log_is_empty                  = 3
                log_not_found                 = 4
                temse_conversion_not_possible = 5
                temse_error                   = 6
                temse_function_error          = 7
                others                        = 8.
    logtable will contain message ID, message type, message number, etc. from T100.

  • How to find the Data Entered Date and User Name?

    Dear Team,
    An End User feeds a data wrongly in KP26. I would like to find by whom it was entered and when? i.e, user name and Date of particular entry.
    Regards
    R.Thillai govindrajan

    Hi Thillai,
    I don't think you can find that information now. If you have switched on trace on that user before he changes, you would have got those details in trace file.
    Thanks,
    Siva Kumar

  • How to make the date to be entered as dd-mon-rrrr  using form personalizati

    Hi friends,
    how to make the date entered to be dd-mon-rrrr format.....
    the date should be entered only in this format...or esle it should not accept the date
    how to do this with form personalization.....
    thanks

    1) Instead of personalization, set ICX: Date format mask profile appropriately using sysadmin responsibility at the appropriate level.
    2) If you have to use this new format just for one form, then use personalization to set the profile option in the when-new-form-instance. But unsetting it will be a problem.
    I recommend option 1 above.
    Hope this answers your question,
    Sandeep Gandhi

  • How to clear the data in my page after user enter submit button

    hi......
    how to clear the data's in my page after user enter submit button. Actually while pressing first time itself the data is uploaded in database.

    Hi Nazeer,
    Instead of doing it on the same button better create a separate button for this functionality, As per my understanding you want to clear these fields to create new record so that you can enter a new record so for this you just need to insert a new row in VO.
    Still if you want to do it on the same button then you need to put the check that particular record is not dirty if it is not then create new record else create new record.
    One more thing if you will clear on the second click of a button how will you update your record??
    Regards,
    Reetesh Sharma

  • How to get the user entered data?

    Hi all,
    I have created an HTMLB DynPage component.
    In That i have created my input screen with textboxes using response.write method.
    i have added one onConfirm event on which the data whould validate.
    so onConfirm method im trying to get the data with request.getParameter method which returns null...
    how to do...how to get the user entered data to do my validations...can anyone plz advice.
    Thanks,
    Viswes

    Hi
    inputfield or textbox component entered directly using response.write(...) are not htmlb , but html.
    to create portal input field (ie HTMLB), you should do something like
    this in the doProcessBeforeOutput member function
    InputField field1 = new InputField("Id1");
    field1.setSize(8); // 8 characters
    this.getForm().addComponent(field1);
    and in doProcessAfterInput member function
    InputField field1 =
    (InputField) this.getComponentByName("Id1");
    you can then manipulate the content of the field.
    Hope this help,
    Guillaume

  • How to enable/disable the input fields based on the data entered/user action in the web dynpro abap?

    How to enable/disable the input fields based on the data entered in the web dynpro application abap?  If the user enters data in one input field then only the next input field should be enabled else it should be in disabled state. Please guide.

    Hi,
    Try this code.
    First create a attribute with the name readonly of type wdy_boolean and bind it read_only property of input field of which is you want to enable or disable.
    Next go to Init method.
    Set the readonly value as 'X'.
    DATA lo_el_context TYPE REF TO if_wd_context_element.
         DATA ls_context TYPE wd_this->element_context.
         DATA lv_visible TYPE wd_this->element_context-visible.
    *   get element via lead selection
         lo_el_context = wd_context->get_element( ).
    *   @TODO handle not set lead selection
         IF lo_el_context IS INITIAL.
         ENDIF.
    *   @TODO fill attribute
    *   lv_visible = 1.
    *   set single attribute
         lo_el_context->set_attribute(
           name =  `READONLY`
           value = 'X').
    After that Go to the Action  ENTER.
    First read the input field ( first input field, which is value entered field) , next give a condition
    if input value is not initial  then set the readonly value is '  '.
    DATA lo_nd_input TYPE REF TO if_wd_context_node.
         DATA lo_el_input TYPE REF TO if_wd_context_element.
         DATA ls_input TYPE wd_this->element_input.
         DATA lv_vbeln TYPE wd_this->element_input-vbeln.
    *   navigate from <CONTEXT> to <INPUT> via lead selection
         lo_nd_input = wd_context->get_child_node( name = wd_this->wdctx_input ).
    *   @TODO handle non existant child
    *   IF lo_nd_input IS INITIAL.
    *   ENDIF.
    *   get element via lead selection
         lo_el_input = lo_nd_input->get_element( ).
    *   @TODO handle not set lead selection
         IF lo_el_input IS INITIAL.
         ENDIF.
    *   get single attribute
         lo_el_input->get_attribute(
           EXPORTING
             name =  `VBELN`
           IMPORTING
             value = lv_vbeln ).
    if lv_vbeln IS not INITIAL.
        DATA lo_el_context TYPE REF TO if_wd_context_element.
        DATA ls_context TYPE wd_this->element_context.
        DATA lv_visible TYPE wd_this->element_context-visible.
    *  get element via lead selection
        lo_el_context = wd_context->get_element( ).
    *  @TODO handle not set lead selection
        IF lo_el_context IS INITIAL.
        ENDIF.
    *  @TODO fill attribute
    *  lv_visible = 1.
    *  set single attribute
        lo_el_context->set_attribute(
          name =  `READONLY`
          value = ' ' ).

Maybe you are looking for