How to Add and delete a row while using Abstract Table Model

Hi,
I need to do the following functionalities in JTable.I've done tht but a small problem.
1. Adding a row (Using addRow() method from DefaultTableModel).
2. Deleting a row(Using setRowCount() method from Default Table Model).
3. Sorting the table based on the selection of column(Using TableSorter which is using AbstracTableModel).
As the sorting is mandatory i've to change my model to Abtract Table Model
The problem is this Abstract Table Model doesn't have any methods to Add a row or deleting a row (setRowCount()).If anybody has written any utility method for this using Abstract Table Model help me.

Using TableSorter which is using AbstracTableModel).If your talking about the TableSorter class from the Swing tutorial, then you create the TableSorter class by passing it a TableModel. There is no reason you can't use the DefaltTableModel.
I changed the code in TableSorterDemo as follows:
        String[] columnNames = {"First Name",
                                        "Last Name",
                                        "Sport",
                                        "# of Years",
                                        "Vegetarian"};
        Object[][] data = {
            {"Mary", "Campione",
             "Snowboarding", new BigDecimal(1), new Boolean(false)},
            {"Alison", "Huml",
             "Rowing", new BigDecimal(3), new Boolean(true)},
            {"Kathy", "Walrath",
             "Knitting", new BigDecimal(2), new Boolean(false)},
            {"Sharon", "Zakhour",
             "Speed reading", new BigDecimal(20), new Boolean(true)},
            {"Philip", "Milne",
             "Pool", new BigDecimal(10), new Boolean(false)}
          DefaultTableModel model = new DefaultTableModel(data, columnNames)
               public Class getColumnClass(int c)
                    return getValueAt(0, c).getClass();
        TableSorter sorter = new TableSorter(model);
//        TableSorter sorter = new TableSorter(new MyTableModel()); //ADDED THIS

Similar Messages

  • Add and Delete a row in table

    Hi Expert,
    In SAP interactive form OFFLINE Scneario.
    I have a deep structure. In which i am using other structures like kna1, knb1, knvv.
    Now in KNVV is again a deep structure in which i have a table type.
    Now a draged and droped this table type to my layout  so i got a table.
    I Need to have two buttons ADD and Delete, To add and delete a row in table repectvily.
    I saw other threads also but get not do it.
    My table type attribute's name in KNVV structure is VLACT.
    I write following code on click action of ADD button
    data.#subform[0].Button1::click: - (FormCalc, client) -
    VLACT.row.instanceManager.addInstance(1);
    xfa.form.recalculate(1);
    but it shows error msg
    accessor "VLACT.row.instanceManager.addInstance(1);"
    is unknown.
    Also i am not able to see tabel itself wich i draged and droped. Only two buttons are there.
    Plz help
    Thanks ? Regards,
    Arvind

    Hi Otto,
    This is the code i am using to add new row.
    Also all the settings in form are correct like "Repeat row for each data item" etc.
    I want to have at most 7 rows.
    var nTableLength = Table1.nodes.length; 
      var nNumRow = 0;
        for (var nCount = 0; nCount < nTableLength; nCount ++)
          if ((Table1.nodes.item(nCount).className == "subform") & (Table1.nodes.item(nCount).name !== "HeaderRow"))
           { nNumRow = nNumRow + 1; }
               if (nNumRow == 7)
               { xfa.host.messageBox("The maximum allowable number of rows is 7. You cannot add any more rows.", "Warning", 3); }
           else {
                  Table1.Row1.instanceManager.addInstance(1);
                  xfa.form.recalculate(1);
                   xfa.host.messageBox("row added" );
    I get the msg form the statment        xfa.host.messageBox("row added" );
    But i can not see the newly added row
    Plz help
    Thansks & Regards,
    Arvind

  • How to add and delete content on device from iTunes

    I cannot find the way to add and delete content on my devices from the new iTunes. I don't understand why they changed the way it worked without any tutorials or hints at how to use the new iTunes app. I can see my device, I can see that music is on there, but I cannot unselect songs or content to get rid of it. Also, my apps do not show up on the apps list, I can see the screens with the apps on them and can delete them from that but the list is not working. I am using Yosemite and iTunes 12.01

    If you select your device in iTunes then on the left-hand side of iTunes you should see a Settings heading with categories below it which you can use to select what to sync from your iTunes library to the device, and below that an On My Device heading with categories below it listing what is on the device.
    For the Apps tab, the listbox of apps on my Mac's iTunes doesn't always populate until I've scrolled up/down the window. If yours doesn't populate then you have your apps downloaded and stored in your Mac's iTunes library - the listbox shows what you have in your computer iTunes library, if your library is empty then the listbox will remain empty.

  • How to find and delete matching row in ADF BC

    Hi,
    I have a table with simple fields and I have created the java class for this entity also
    Person
         - Person_Id (PK)
         - Person_NameI wanted to create an application module method to search for the entity that matches certain name
    but I cant find the code to do this.
    public class AppModuleImpl{
      public boolean deletePersonByName(String personName)
        EntityDefImpl personDef = PersonImpl.getDefinitionObject();
        //How to get all rows and find the matching name then delete the row
        return false;
    }Thanks
    Jdev 11.1.1.5

    Ramandeep Nanda wrote:
    getfilteredRows does that, you can iterate and delete the rows after filtering on any attribute in view object it does not have to be a primary key.Hi Ramandeep,
    I got the idea and I somehow was able to do what I want.
      public boolean deletePersonByName(String personName)
        PersonViewImpl personView = this.getPersonView();
        Row[] matchingRows = personView.getFilteredRows("PersonName", personName);
        if(matchingRows!=null)
          for(Row rowTemp : matchingRows)
            PersonViewRowImpl personRow = (PersonViewRowImpl) rowTemp;
            personRow.remove();
            try
              getDBTransaction().commit();
            }catch(JboException ex)
              throw ex;
        return true;
      }But somehow I got this idea, supposed I have this data
    PersonId          PersonName
    1               MANDER
    2               MANDERRY
    3               JERRYThe code getFilteredRows somehow only perform an 'exact' match but what if I want to delete both of the data
    with PersonName 'MANDER' above.
    My current code only removes the person with name 'MANDER' and not the 'MANDERRY'
    Thanks

  • How to insert and delete a row after filter applied

    I thought I had figured out the solution to this problem but apparently not...
    How do you insert a new row into a JTable after a filter has been applied? The problem is once the data is filtered when I add a row, I'm getting an ArrayIndexOutOfBoundsException : 182 which is the number of rows for the entire dataset.
    The first line in the exception is: DefaultRowSorter.setModelToViewFromViewToModel
    I've tried to use, getRowSorter().convertRowIndexToView(int) but I can't get it to work. Can anyone offer any assistance?
    Thanks

    I also got that problem recently and after debuging for a while I figured out, that it was resulting from an error in my table's model: When the model received new items to display I
    1.) Fired an delete event for the old items
    2.) Fired an insert event for the new items
    Problem was that when firing the delete event I didn't already assigned the new items to the model. Therefore it had still the old row count.
    Maybe you have also a faulty table model?...

  • Web Dynpro for ABAP:How to insert and delete a row in a table

    I have a table.
    My requirement is to insert a row into the table and i want to delete a particular row also.
    How can i do it.
    Plz reply me..

    Try the Web Dynpro for ABAP forum:
    Web Dynpro ABAP
    Kind Regards
    Stefanie

  • How to add and delete certain songs on iPod

    I'm not a whiz that this stuff but I just want to put certain songs from my playlist in iTunes to my iPod, not all but just certain ones. How do you do it? Seems all my songs go to the iPod, what am I doing wrong?

    Probably the easiest way to do it is to set up a playlist for your shuffle. Then plug in the iPod and under the music tab for the iPod, rather than having it sync all your library, instead tell it to only sync that playlist (it should be obvious how to do that when you see the page in iTunes).
    You can now add to or delete from that playlist and those changes to the playlist will be reflected on the shuffle next time you sync it up with iTunes.
    Patrick

  • Examples of Add and Delete buttons in Forms

    Hello, I have group project and we are having a hard time finding examples of how to add and delete records.
    We have tried for the add:
    INSERT INTO order_line VALUES
    (:orders.o_id,
    :order_line.inv_id,
    :order_line.ol_quantity);
    COMMIT;
    And this for the Delete:
    DELETE FROM order_line      WHERE
    o_id = :orders.o_id
    AND inv_id = :order_line.inv_id;
    COMMIT:
    We are just looking for a generic example of how the code should look. Please ignore any errors I may have typed I copied it from a print off.

    Please ask this question in the Forms discussion area instead of the Database discussion area.
    Thanks.

  • How do I delete music from my iPhone and what is the best way to add and delete music?

    How do I delete music from my iPhone and what is the best was to add and delete music to the iPhone?

    See Here...
    iPhone User Guide
    and here
    http://www.apple.com/support/iphone/syncing/

  • How do I add and delete pages to a pdf document?

    How do I add and delete pages to a pdf document?

    Hi Paul,
    Adobe Acrobat has the features to add/delete/extract/crop/insert pages to your PDF files and are much more features.
    Adobe Reader has  a very limited features for editing to PDF files.
    Now you can subscribe to Acrobat Plus and see more information at https://www.acrobat.com/acrobatplus/en/home.html
    Or you can download Acrobat XI Pro for trial version from www.adobe.com.
    thank you.
    Hisami

  • How do i add and delete photos from the screensaver preference window

    How do i add and delete photos from the screensaver preference window?

    Hello, sassy4sue. 
    Thank you for visiting Apple Support Communities. 
    Here is an article that you may find helpful when creating or editing iPhoto albums that you are using as a screen saver. 
    Mac Basics: Using Screen Saver when your screen is idle
    http://support.apple.com/kb/ht2485
    Cheers,
    Jason H. 

  • Fitbit does not sync with healthvault no matter how many times I add and delete it

    My healthvault never shows any information synced from fitbit.com, I have the scales and a tracker and no matter how many times I add and delete it through the fitbit share healthvault page but  it never ever syncs over night. I have left is weeks and
    still nothing in HV.
    I am starting to wonder if HV supports fitbit? Any help would really be appreciated, this is driving me insane.
    Do I need to create a new account? is my account just broken?

    Hi,
    I have spoken with FitBit about this issue and they provided the following:
    Since you have already linked and unlinked your account and still having issues please contact Fitbit Support (http://help.fitbit.com/?cu=1)
    for further assistance."
    Addititionally when you contact FitBit can you please let them know that you have already contacted HealthVault.
    Thanks
    Tomas
    MS HealthVault Support

  • Adding and Deleting Multiple Rows or Columns

    How do you add or delete more than one row or column at a time.

    Robby! wrote:
    That's a great finding!
    I just wrote a feedback requesting a shortcut like this.
    It is a pity though that they desing it to work only if you select the header of the row/column. It should be enabled to work from within any cell in the table.
    Who wrote such an error ?
    These interesting shortcuts behave flawlessly even if the cursor was in D18 for instance.
    (a) I never saw them in the delivered resources.
    (b) they aren't responding to the OP's question which was about "Adding and Deleting Multiple Rows and Columns"
    Yvan KOENIG (from FRANCE vendredi 3 octobre 2008 18:39:01)

  • How to add the delete button

    Hello Guru's and Experts.
    I am working on a change request , the change request is as follows
    Once a cost simulation is run for a maintenance item and the data transferred to BI, it cannot be deleted from BI, only overwritten with an updated cost simulation. In the instance where the such items are no longer required to be included in the simulation, it must be made possible to delete the simulation costs in BI.
    The current design in my project significantly increases the effort required to identify unwanted cost simulations and greatly increases the potential for incorrect data to be used in Budgeting and forecasting.
    My question is how to add the delete functionality in the report. is it acheavable through the portal or WAD,
    iam new to SAP BI , if possible can anyone kindly suggest me the steps to do this functionality.
    Appreciate your quick response..
    Thanks
    Ravi.

    Hi Guru
    Thanks for your valuable information.
    We got the requirment changed now from the users , the delete button should display in the report, i mean in protal, Now the user wants to delete with the selection criteria, for example, once the user hits the row in the report, that means if he selects the Main work center, and selects the delete button , he wants all the data related to that main work center to be deleted.  and another senario is what ever row the user selects  the characteristics in the row, for example, if the user select  for any row, i mean it can be any cost center or fiscal year, maintaiance item, cost elements, ..etc.  
    Once the user  selects the row and hit the delete button,  and he wants to hit the save save button in the report to make sure it deleted, the other way around , if the dont want to hit save, then he wants the data to be in the report.
    In the above  scenario's  can  you please suggest me with the steps how can we acheive it.
    Please reply back if you need any other info., Apprieciate your quick response. its very urgent requirment which we have to start...
    sorry to bother u..
    Thanks
    Ravi.

  • Hello, I would like to know how to add or delete single cell in numbers.

    Hello, I would like to know how to add or delete single cell in numbers.

    If by delete you really mean clear the contents of a cell, then just click once on the cell and hit the 'delete' button.
    Before:
    After hitting delete button:
    In some circumstances you can actually delete one cell.
    For example here, I make this choice:
    Resulting in this:
    So it's not strictly true that Numbers does not delete one cell, ever.  It can if you have a one-column table. 
    So never say never or not ever! Enough pedantry for today!
    SG

Maybe you are looking for

  • Short Dump DYNPRO_MSG_IN_HELP in Conversion Exit

    Hi Gurus, I've written the following conversion exit: FUNCTION CONVERSION_EXIT_ZBZEI_INPUT. *"*"Lokale Schnittstelle: *"  IMPORTING *"     VALUE(INPUT) *"  EXPORTING *"     VALUE(OUTPUT) *"  EXCEPTIONS *"      INPUT_NOT_VALID   DATA : CPI_OUT(4) type

  • "Restoring the window layout" hang - tried everything! HELP!

    I'm in Mavericks and am experiencing that "Restoring the Window Layout" hang that is kinda infamous around these parts. Except that in my case, I've done EVERYTHING that all the other links suggest. I have: *Trashed the Layouts folder (inside Users/m

  • Lost Purchased Songs (Couldn't Find Solution in FAQ)

    Very shortly after downloading a song iTunes crashed (with that error message that asks if you'd like to send an error report). I opened up iTunes again and my song was gone. The money credit I used to purchase the song was gone too. I couldn't find

  • SAP Fashion Management !

    Hi, Last month, SAP introduced an add-on module called SAP "Fashion Management" specifically targeting apparel customers, who are into retail and manufacturing. I've few questions with regards to this module. Can you please answer, 1) Is Fashion mana

  • Data pump to ASM?

    Is it possible to export to an asm directory? I tried this: CREATE DIRECTORY "DGT01_EXP" AS '+DGT01/EXP'; (yes, this directory does exist in ASM) But when I tried using this directory for expdp, I got this error. $ expdp datapump/&pw schemas=test dir