JTable moving items strangeness (desperate now)...

Hi there,
I've got a major problem that I just can't figure out. I've got two JTables, each with an instance of the
below datamodel. I've got two buttons. I want to highlight certain rows on the left JTable and use one of
the buttons to move across the selected items to the JTable on the right.
Two problems - the first is that the selected items are copied across fine, but instead of removing the
selected rows from the left JTable after copying to the right JTable, it leaves a random one. The other
problem is that if I highlight rows from near the bottom of the lefthand JTable, I get an
ArrayIndexOutOfBoundsException.
What the hell is going wrong here? I'm at a total loss.
This is my datamodel for both JTables...
import javax.swing.table.AbstractTableModel;
import java.util.Collection;
import java.util.ArrayList;
import java.util.Vector;
import java.util.Map;
import java.util.List;
import java.util.Iterator;
import java.util.Set;
import commonfiles.Utility;
public class ListDataModel extends AbstractTableModel implements Cloneable {
    private final int NUM_COLUMNS = 3;
    private Vector theRowData;
    private String[] columnNames = {"USERS_REFNO", "CODE", "USER_NAME"};
    // Constructor : Create empty data model.
    public ListDataModel() {
        theRowData = new Vector();
    // Constructor : Create data model from another collection.
    public ListDataModel(Collection someCollection) {
        theRowData = new Vector();
        theRowData.addAll(someCollection);
    public ListDataModel(List arrayCollection) {
        ArrayList theColumnArray;
        Map rowMap;
        theRowData = new Vector();
        for (int i = 0; i < arrayCollection.size(); i++) {
            rowMap = (Map)arrayCollection.get(i);
            theColumnArray = new ArrayList();
            theColumnArray.add((Object)rowMap.get(columnNames[0]));
            theColumnArray.add((Object)rowMap.get(columnNames[1]));
            theColumnArray.add((Object)rowMap.get(columnNames[2]));
            theRowData.add(theColumnArray);
    public Object clone() {
        try {
            return super.clone();
        } catch (CloneNotSupportedException cnse) {
            throw new RuntimeException(cnse.toString());
    public Object getValueAt(int rowIndex, int columnIndex) {
        ArrayList theColumnArray;
        theColumnArray = (ArrayList)theRowData.get(rowIndex);
        return(Object)theColumnArray.get(columnIndex);
    public List getRowAt(int rowIndex) {
        return (ArrayList)theRowData.get(rowIndex);
    public void removeRowAt(int rowIndex) {                       // <- Exception thrown here.
        theRowData.removeElementAt(rowIndex);
    public void addRow(List rowObject) {
        theRowData.addElement(rowObject);
    // Check to see if a particular Table cell is editable.
    // In this model, none of the cells are directly editable.
    public boolean isCellEditable(int rowIndex, int columnIndex) {
        return false;
    public int getColumnCount() {
        return columnNames.length;
    // Return the column headers.
    public String[] returnColumnNames() {
        return columnNames;
    // Return the name of a specific column.
    public String getColumnName(int col) {
        return columnNames[col].toString();
    public int getRowCount() {
        return theRowData.size();
    public Vector returnAllData() {
        return theRowData;
}...and this is the code I'm using when I press the button to move the selected rows from the left JTable to
the right JTable.
public void actionPerformed(ActionEvent e) {
        int[] selectedRows;
        List listItem;
        // Event that happens when the List Add (>>) button is pressed.
        if (e.getSource() == btnListAdd) {
            // Get the number of selected (hightlighted) rows.
            selectedRows = this.tableUserList.getSelectedRows();
            if (selectedRows.length > 0) {
                for (int row = 0; row < selectedRows.length; row++) {
                    listItem = ((ListDataModel)tableUserList.getModel()).getRowAt(selectedRows[row]);
                    ((ListDataModel)tableExcludeList.getModel()).addRow(listItem);
                for (int row = 0; row < selectedRows.length; row++) {
                    ((ListDataModel)tableUserList.getModel()).removeRowAt(selectedRows[row]);
                tableUserList.clearSelection();
                tableUserList.revalidate();
                tableUserList.repaint();
                tableExcludeList.revalidate();
                tableExcludeList.repaint();
    }Here is the stacktrace for the IndexArrayOutOfBoundsException...
Exception occurred during event dispatching:
java.lang.ArrayIndexOutOfBoundsException: 22 >= 22
at java.util.Vector.removeElementAt(Vector.java:517)
at ListDataModel.removeRowAt(ListDataModel.java:66)
at ExcludeListFrame.actionPerformed(ExcludeListFrame.java:177)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:17
86)
I'm in desperate need of help with this. The errors just don't make logical sense to me. Little help folks?
Thanks.

Here's your problem :
When you remove an element from your Vector, its size decreses.
Let's say you have 10 objects in your Vector :
the first time you remove an element, its size will become 9 (from 0 to 8)... and imagine that the second index of your int array is 9 !! you are out of bounds!!
what you should do is pass the entire indexes array to your data model, then create a new Vector (let's call it vect2) that you will feed with the objects pointed by your indexes.
then you remove the whole vector :
myData.removeAll(vect2);

Similar Messages

  • After trying to update itunes it now hangs moving items into place.

    I get the error that this copy of itunes is corrupted or is not installed correctly.  Please reinstall itunes (error -42037).  I have attempted to reinstall but the install process hangs at moving items into place.  I have left it over night, before manually shutting down and trying again, and then left it all day.  Still hangs, whilst hanging the time remaining goes up from less than a minute, to 1 hour 6 minutes, to 2 hours 50 minutes etc.  I need to fix quickly as I am setting up a new phone and was able to restore all but my music from icloud.  I need my music and playlists set up before tomorrow.  Thanks

    Hi, reinstalling iTunes should not mess with your music et cetera (however some users have suggested on here that it did), but keeping a backup is always recommended anyway.
    You can visit this link to install iTunes, the older seemingly corrupted version will be replaced...Troubleshooting iTunes installation on Mac OS X - Apple Support

  • Returning a ZERO on Slow-Moving Item without transaction

    Hi all,
    Via a multi-provider, we have implemented several slow-moving item in our reports, eg we return all the value of some dimensions whether we have transaction or not on these dimension values.
    Now for dimension value for which we have no transaction it returns in Bex an empty result on the key figure instead of a zero, is there a way to force BW to put a zero on a slow-moving item without any transaction?
    Thanks in advance for your assistance
    David

    Hallo
    FI you go to the Query Designery --> Property Display than you can cusotmioze how to display the zero. You probably have the option Zero Values Display as Blank.
    I hope this can help you
    Mike

  • I have been using my Apple ID in India and recently i moved to Spain and now i can not see my indian apps.it says my apple ID is valid for only spanish store.how to download apps from Indian store being in Spain.

    I have been using my Apple ID in India and recently i moved to Spain and now i can not see my indian apps.it says my apple ID is valid for only spanish store.how to download apps from Indian store being in Spain.

    Did you try to change the location  in Settings/iTunes & AppStore/AppleID -> view Apple ID, log in ->Country/Region -> India?

  • Custom Report for slow and fast moving items

    Dear Xperts,
    My client wants to develop a new report for slow and fast moving items, I checked the std report MC46 however as per std SAP design this report does not consider the special stock like project stock (Q)...could you please help me to know how can develop this new report with following input and output fields?
    Input fields:
    Plant
    Material
    Material Group
    MRP Area
    Special Stock Indicator
    Special Stock (Type)
    Output Fields:
    Material
    Material type
    Material group
    MRP Controller
    MRP Area
    ABC indicator
    Material price
    Category field – Slow, Fast, Non-moving
    Current Stock
    Last Issue Date
    Thanks in Advance
    Regards
    Rahul

    Dear Rahul,
    If you required  project stock and consignment stock with valuated stock report in same place you need to generate new info structure as given below link. Or you can go with customized report with abaper.
    Info structure validation
    Regards
    Sanjeet Kumar

  • Report on Slow-moving item in sap MM

    Dear All,
    I am facing problem in preparing functional specification for a Z report.The requirement details are given below
    MC46 gives me a list of all items that have not got consumed since the last period (defined in terms of 'no of days' on the screen before executing the report) This report  give  a list of items that have shown nil consumption in the defined period. This list helps us analyze and categorize these items as Slow-moving or Non-Moving items. The output is in terms of Part no and Part Description.
    Example; Suppose we are executing the transaction  on say 29.10.2013.The system ,say give list of materials X1,X2 and X3 with nil consumption in the defined. The transactions suppose is again executed
    on 29.10.2011.The report  say again give a list of materials X1 and X3 with nil consumption. The material
    X2 is excluded from the report  as it might have been consumed in certain business processes(either issued to cost center or issued to production).
    The client wants a report from where it is possible to determine a list of materials along with consumption
    and the date on which the  material have moved out of stock for consumption. In otherworldu2019s we can say the report should give :
                        stock on starting  date(say 29.10.2013)
                        Consumption/movement in terms of date and quantity
    The problem is that when the transaction MC46 is run the next time(say on 29.11.2013 or any day after
    29.10.2013) there might be materials which might have got consumed in the interim period and therefore have got excluded from the latest list. We need to have a look at these interim materials to analyze their movement/consumption.MC 46  Report does not give details of openinf stock, closing stock and the purpose for which the stock have moved out of stock
    The client wants a Z-Report which will give details about the material which have moved out of stock when the report will be executed ,opening stock,closing stock.The detail requirement are given below
    The report will assist the client to get a list   of all such items with reference to a starting date and their movement in the period (period from the starting date to the run date)
    Selection Screen(Input)
    Opening Date
    Closing date
    Movement type
    Plant
    Output
    Material nos(Material which have moved out of stock when the program was last executed)
    Movement type
    Movement date
    opening stock qty
    opening stock value
    closing stock qty
    closing stock value
    I request if any one can help in preparing functional specifications.

    thanx for reply ,
    but plez read the requirement above mention.i understood  what are you saying .

  • I moved iTunes folder location, now all my personal song ratings and playlists are gone.  How can I get them back?  All the iTunes files are intact, just in a new location.  Running iTunes 11.1.5.5

    I moved iTunes folder location, now all my personal song ratings and playlists are gone.  How can I get them back?  All the iTunes files are intact, just in a new location.  Running iTunes 11.1.5.5 on Windows 7

    Put everything back the way it was.
    Them move the folder correctly.
    http://support.apple.com/kb/ht1364

  • After reformatting my 1 Tb WD ext drive and tinkering with the "exclude these items" list, I now get the following error message from Time Machine:Are you sure you want to back up to the same device your original data is on? the WD disk has mounted??

    After reformatting my 1 Tb WD ext drive and tinkering with the "exclude these items" list, I now get the following error message from Time Machine: "Are you sure you want to back up to the same device your original data is on?"  I've reformatted in Disk Utilities...not sure what I did wrong.  Any help would be appreciated.

    Not sure what you mean by "booted" from it.
    If the Mac OS is installed on the external drive, then it's possible to start up from it, just as you do from your internal drive. Please open the Startup Disk preference pane in System Preferences, and verify that your internal drive is selected as the startup disk.
    Assuming that's the case, then it may be that your TM settings have been corrupted. Turn off TM, then move or delete the file /Library/Preferences/com.apple.TimeMachine.plist. Turn TM back on, recreate your settings, and try again.

  • My MacBook pro is freezing at the "moving items into place" phase. I have to restore from time machine each time. I'm talking about the 10.7.4 update

    I can't seem to get the 10.7.4 update to work. It constantly freezing at the "moving items into place" phase. I let it run overnight and it's still frozen. I have to restore from time machine backup each time. Any help appreciated.

    this is somethinng like the third post i have read about that update causing troubles...
    But if I read this right- it is still in the install? Had you restarted and repaired permissions BEFORE the download? As well as emptying cache in safari first?
    The other troubles I read had to do with after install, and caused by...oh what was it...it was early morning...an article at CNET news had it...google 10.7.4 update trouble and read the cnet one.

  • Slow-moving items

    Hi,
    How is it that the standard report 0IC_MC01_Q0001, displays just slow-moving as it doesnt seem to have any condition on issued or valued stock it seems to just display all the values but not the above key figures with zero values. Should we create conditions on them. am i missing something.
    Thanks,
    your help will be rightly appreciated

    Hi,
    Generally in R/3 side,
    MC46 is the standard transaction code for the SLOW MOVING ITEMS. In that transaction code u can see all the details about the slow moving items. Through that transaction code u can check what are all the things are missing in BW side.
    Thanks,
    Sankar M

  • Slow Moving Items in 0IC_MC01 Performance issue

    Hi  i am creating slow moving items report (Report which shows materials for which no transaction has been done for last 3 years) on MP 0IC_MC01 in BI7.0.
    MP is based on cube 0IC_C03 and Infoobject 0MATERIAL .
    In query i put rowcount in coloumn with Infoprovider 0material with constant selection but i dont get the option "Display values not posted" . and Issues value and Recved value .
    in rows i put plant , material and material type 
    n put one condition values for issued and Recid = 0 .
    and in filter we have calender year restriction  .
    But the proble is dere are around 25000 materials for each plant and its taking a lot of time to exceute for multiple plants for 1-2 years , can anyone suggest the best way for this report or how performance of this report can be improved .
    Help will be appreciated .

    Its rather better to use infoset on 0IC_MC01 and Material than using MP. The performance issue is coming because of a join between cube and infoobject, which SAP dont suggest to use.
    You ahve to use left outer join to get slow moving items.
    http://help.sap.com/saphelp_nw04/Helpdata/EN/67/7e4b3eaf72561ee10000000a114084/content.htm
    Thanks...
    Shambhu

  • Report on slow-moving items

    Hello gurus,
    I would like to creat a report on slow-moving items in LIS, similar to report RMCBLH30 (TAC MC46).
    But in 'my' report I would like to see only those slow-moving items in stock. RMCBLH30 unfortunatelly gives my all slow-moving items, even those with quantity = 0.
    Could someone please give me a hint on how to do this? Are there any good tutorials in building LIS-reports?
    Thanks in advance
    Alicia

    Hi,
    Please check the last date when any of your stock movement had an accounting impact like GR, GI etc and see whether the data tallies
    In MC46 try for double line display tab. It shows last movement date.
    Also, check for Detailed Display for each material. It will show the details based on which it is picking last movement date and No movement since days.
    From this details you can make out the date which it is taking as last movement......
    MC46 simply counts the number of days since the last issue against each
    material - the more days the slower moving the stock
    If you want to generate a Z-report please take the help of technical consultant...
    regards,
    Patil

  • BEX :Slow Moving Item Scenario

    Hi,
    I am tring to Implement the below Link scenario for Slow Moving Item
    http://help.sap.com/saphelp_dimp50/helpdata/en/3a/d1603d13b5c72ee10000000a114084/content.htm
    The standard Slow Moving Multiprovider id useed for this purpose.
    The Problem where I am stuck is that I can't find  Display Empty Values mention under Section Displaying slow-moving items point no.2 of the above link.
    Thanks
    Aman

    follow steps in this doc:
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/11291595-0501-0010-c881-e02c27261b55

  • Slow moving items report for project stock

    Hi ALL,
    We are using project stock to manage all of our inventory. As the standard slow moving items report (MC46) does not contain project stock (special stock Q), we would like to develop a report then. "Slow moving" should be identified by material, plant, storage location and WBS.
    Has any had this experience? What's the main data logic for this report?
    Thanks a lot!!

    Dear,
    Do One thing.. First goto MB5B - stocks on posting date and select to display only special stock indicator Q (Project). By this you can abstract all Project materials. Save the output into Excel. (The main aim is first abstract the project stock materials into a list with a suitable transactions - MB5B or MB52).
    Then run MC50 or MC46 using these materials saved in excel file.
    Try this.
    Regards,
    Syed Hussain.

  • Slow Moving Item Scenario - Technical content for Queries

    Hello
    Due to preparations for upgrade to BW 7.30 we would make an analysis of not or seldom used BEx reports (queries, workbooks, etc.)
    All of unused objects  should be deleted in advance of an upgrade.
    I checked if there is a query which shows slow moving items  for queries.
    Is there any technical content (query) which reports this scenario for BEx objects?
    Thanks for any advise.

    follow steps in this doc:
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/11291595-0501-0010-c881-e02c27261b55

Maybe you are looking for

  • ALV USER COMMAND

    Hi,    I am using the following code to change the values in the output and update the database table. TYPE-POOLS : SLIS. TABLES : ZVCARE,          ZHR_VCARE. DATA: BEGIN OF IT_ZVCARE OCCURS 0,       PERNR LIKE ZVCARE-PERNR,       CYEAR LIKE ZVCARE-C

  • 10g installation network error in rhel5 in virtual tool box

    Hi I have visited the links ... and done everything... but still showing.... at the time of oracle 10g installation at PRoduct Specific Prereqisite Checks Checking Network Configuration Requirements... Actual Result : Unknown Host Exception has Occur

  • How can i make a suggestion for a new IOS

    Hello everybody y would like to know if i can make any suggestion for a new IOS cause there is some new things y would like it to have.Thanks.

  • CONNECTION OF SPEAKERS TO PAVILION 500 SERIES DESKTOP

    Just bought first desktop PC a Pavilion 500-312ns desktop that came with a Pavilion 22xi  monitor and all seemed fine until i realised that  the monitor has no speakers or  any options to do so .So my question is  how can i connect speakers to the de

  • DHCP on Sonicwall with UC320

    Hello! I needed help setting up a netowrk. How can I have a sonicwall act as a DHCP server for the UC320 I have? The computers are connected via LAN. And the Sonicwall is connected via WAN. Thanks for your help.