Multiple selection in JTable for deletion

Dears,
I'm using Jdeveloper 9.0.3.3 on 8.1.7 Oracle DB.
I noticed that when a JTable is bound to a View object ==> only one row can be selected.
My situation -which I think is very common- I have a screen with JTable where I can edit a row and commit my updates or select multiple selection in JTable and delete them at once ; thats what I need.
It is very like the test of any application module but allow multiple selection and deletion in JTable for user's selected rows.
How this could be done in JClient?
Thankx in advance.

Thanks for your suggestions! They both would work as workarounds, I think. I tried another way:
Following code changes a TableBinding bound JTable's selection model to Multi select (thanks to Shailesh!!).
void setMultiSelectionModel(JTable tbl)
class MultiSelectionListListener implements javax.swing.event.ListSelectionListener
ListSelectionModel defSelModel;
MultiSelectionListListener(ListSelectionModel model)
defSelModel = model;
public void valueChanged(javax.swing.event.ListSelectionEvent e)
if (!e.getValueIsAdjusting())
ListSelectionModel listModel = (ListSelectionModel)e.getSource();
int leadIndex = listModel.getLeadSelectionIndex();
if (leadIndex == listModel.getAnchorSelectionIndex()
&& leadIndex == listModel.getMaxSelectionIndex()
&& leadIndex == listModel.getMinSelectionIndex())
//change currency on the bound iterator only if
//one row is being selected.
defSelModel.setSelectionInterval(leadIndex, leadIndex);
ListSelectionModel newModel = new DefaultListSelectionModel();
newModel.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
newModel.addListSelectionListener(new MultiSelectionListListener(tbl.getSelectionModel()));
tbl.setSelectionModel(newModel);
This fixes the bug if you select some rows and then select a row before the first selected one. Seems to work great.

Similar Messages

  • Why i cannot delate my photos when i press select? Icon for delete is not appear.

    Why i cannot delate my photos when i press select? Icon for delete is not appear.

    Did you use iTunes to sync those photos onto your device? If so then the only way to get them off is to use iTunes to sync them off.
    When you sync them on you choose a folder and say 'put all the photos in here on my iPad', so to take them off you need to deselect that folder or remove photos from that folder and sync to take them off.

  • You Cannot select assembly order for deletion error with BAPI_SALESORDER_CAHNGE after EHP6 upgrade

    Hi All,
    We are using Z transaction to update Wbs element data to sales order line item through BAPI_SALESORDER_CHANGE. After EHP6 upgrade while updating Wbs element data to old sales orders(Created before EHP6 upgrade)  we are getting  You cannot select assembly order < order number> for deletion (V1 748) error in BAPI return table, For multiple Sales order run.
    But if  we run the same order individually it is getting processed successfully. W e are passing the same values in individual and multiple case.
    We debugged the BAPI and found one more error related to Authorization, But BAPI return table is giving different error (V1 748)message. Please help us in finding the issue.

    Hi Sujay..
    Please check.
    http://help.sap.com/saphelp_47x200/helpdata/en/b7/58c4c87e0811d2b66a0000e82d8bd1/frameset.htm

  • Multiple selection in JTable

    Hi ,
    The problem is to select multiple rows and columns in the JTable like that of a excel application and have the focus on the first column of the last row. for example if select cells from ( 1,1 ) to ( 4,4), after selection the focus should be in cell (4,1). i have written a prgram( which is below) which uses listSelection to find out the cells which are selected. i found out the cells which are selected also. but i do not know how to get the focus on that cell. i have attached the code below also.. i want to know whether there is any method which set the focus to the particular cell. Can the problem above can be solved in any other way..or a simpler way..
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.table.*;
    class myTable {
    public static void main(String a[] ) {
              JFrame myframe = new JFrame();
              JTable jtable = new JTable(10,10);
              jtable.setCellSelectionEnabled(true);
         // add the listener to the table
    ListSelectionModel listSelectionModel;
         OSSTableSelectionHandler obj = new OSSTableSelectionHandler(jtable,10,10);
         listSelectionModel = jtable.getSelectionModel();
    listSelectionModel.addListSelectionListener(obj);
         myframe.getContentPane().add(jtable);
         myframe.show();
    } // end of public static void main
    } // end of class of myTable
    class OSSTableSelectionHandler implements ListSelectionListener {
                   JTable table;
         int row;
                   int col;
    OSSTableSelectionHandler(JTable tab, int r, int c ) {
         table = tab;
    row = r;
              col = c;
    public void valueChanged(ListSelectionEvent e) {
    ListSelectionModel lsm = (ListSelectionModel)e.getSource();
                   int i = 0,j = 0;
    int firstIndex = e.getFirstIndex();
    int lastIndex = e.getLastIndex();
    boolean isAdjusting = e.getValueIsAdjusting();
    if (lsm.isSelectionEmpty()) {
    System.out.println(" Selection empty ");
    } else {
    // Find out which indexes are selected.
                        int maxrow = 0 ;
    int minIndex = lsm.getMinSelectionIndex();
    int maxIndex = lsm.getMaxSelectionIndex();
    for ( i = minIndex; i <= maxIndex; i++) {
    if (lsm.isSelectedIndex(i)) {
                                  if ( maxrow < i )
                                       maxrow = i;
                                  for (j = 0;j < col ;j++ )
                                       if ( table.isCellSelected(i,j) )
                                            System.out.println("The selected index is " + i + " " + j);
                             } // end of if                    
    } // end of for
                   // after this maxrow contains the last row that has beeb selected
                   // this for loop is to find out the first column in the maxrow that is selected
                   for (j = 0;j < col ;j ++ )
                        if ( table.isCellSelected(maxrow,j) )
                                  break;
                   // set the focus to the column ( maxrow, j )
    } // end of else
    } // end of fucn value changed
    } // end of class OSSTableSelectionHandler

    Whic cell is focused depends on where you begin your selection. The cell that you press your mouse first will be the focused one. Here is how I implement the mutiple selection functionality in a JTable as what MS Excel provides. This class is independent of my any other package. your table has to have column headers and a upper left JLabel corner(int the scroll pane containing the table) in order to make this class which I named TableSelectionAdapter function properly. You can revise and imporve it as you need, however.
    package petrochina.riped.gui.table.tableadapter;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.table.*;
    import javax.swing.event.*;
    import java.awt.datatransfer.*;
    import java.util.*;
    * Enables multiple selection funtionality on <code>JTable</code>s.
    * @author Guanglin Du,SEC of Riped, PetroChina,
    * [email protected]
    * @version 1.0 2002/09/16
    public class TableSelectionAdapter extends MouseAdapter {
    private String newline = "\n";
    private boolean DEBUG = false;
    // private boolean DEBUG = true;
    private JTable myTable = null;
    private boolean shiftKeyDown = false;
    private boolean ctrlKeyDown = false;
    private int firstSelectedColIndex = -1;
    * Constructs with a <code>myTable</code> to simplify its reusability.
    * Guanglin Du, 2002/09/19
    * @param myTable     a <code>JTable</code>
    public TableSelectionAdapter(JTable myTable) {      
    this.myTable = myTable;
    initTableSelection();
    * The initTableSelection method: initializes the row/column/cell
    * selection functionality of the table.
    * Guanglin Du, 2002/09/19
    public void initTableSelection() {      
    getMyTable().setSelectionMode(
              ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
         //Cell selection
         myTable.addMouseListener(new MouseAdapter() {
         public void mousePressed(MouseEvent e) {
              myTable.setColumnSelectionAllowed(true);
              myTable.setRowSelectionAllowed(true);
         setMyKeyListener(); //shift/control key listener
         //column selection functionality
         JTableHeader myTableHeader = getMyTable().getTableHeader();
         myTableHeader.addMouseListener(new TableHeaderListener());
         //enalbles select-all functionality
         setSelectAllFunction();
    * This setSelectAllFunction isto set the select-all functionality
    * when the upper left corner label of the JTable is clicked.
    * Note: JTable's parent JScrollPane has to be found.
    * Guanglin Du, 2002/09/19
    public void setSelectAllFunction() {      
    Container firstParent = getMyTable().getParent();
    if (firstParent instanceof JViewport) {
         Container secondParent = firstParent.getParent();
         if (secondParent instanceof JScrollPane) {
         JScrollPane myScrollPane = (JScrollPane)secondParent;
         JLabel myLabel =
              (JLabel)myScrollPane.getCorner(JScrollPane.UPPER_LEFT_CORNER );
         myLabel.addMouseListener(this);
    * Detects shift/control key state.
    * DGL, 2002/09/18
    public void setMyKeyListener() {
         getMyTable().addKeyListener(new KeyAdapter(){               
         //keyPressed
         public void keyPressed(KeyEvent e){
              //shift key state
              if(e.isShiftDown())     shiftKeyDown = true;                    
              //control key state
              if(e.isControlDown()) ctrlKeyDown = true;
    //keyReleased
         public void keyReleased(KeyEvent e){
              //shift key state
              if( !e.isShiftDown() ) shiftKeyDown = false;                    
              //control key state
              if( !e.isControlDown() ) ctrlKeyDown = false;
    * Adds the table header listener to enable single/multiple column selection.
    * DGL, 2002/09/17
    public void setTableHeaderListener() {
         JTableHeader myTableHeader = myTable.getTableHeader();
         myTableHeader.addMouseListener(new TableHeaderListener());
    * Returns the <code>myTable</code> property value.
    * @return myTable the table that this class handles
    public JTable getMyTable() {
    return myTable;
    * Sets <code>myTable</code> property value of this class.
    * @param myTable the table that this class handles
    public void setJTable(JTable myTable) {
         this.myTable = myTable;
    * Returns the shiftKeyDown property value.
    * @return boolean, Guanglin Du, 2002/09/18
    public boolean getShiftKeyDown(){
         return shiftKeyDown;
    * Return the ctrlKeyDown property value.
    * @return boolean, Guanglin Du, 2002/09/18
    public boolean getCtrlKeyDown(){
         return ctrlKeyDown;
    * This inner class handles the column selection, the same
    * behavior as MS Excel.
    * Guanglin Du, 2002/09/18
    class TableHeaderListener extends MouseAdapter {
    public void mousePressed(MouseEvent e) {    
         stopLatestCellEditing(); //To save the data being edited
         if(DEBUG) System.out.print("mousePressed on ");
         JTableHeader myColumnHeader = (JTableHeader)e.getSource();
         Point myPoint = e.getPoint();
         int selectedColIndex = myColumnHeader.columnAtPoint(myPoint);
         if(DEBUG) System.out.print("the header of column "
              + selectedColIndex+newline);
         JTable table = myColumnHeader.getTable();
         //The following column selection methods work only if these
         //properties are set this way
         table.setColumnSelectionAllowed(true);
         table.setRowSelectionAllowed(false);
         int myRowCount = table.getRowCount();
         //makes this table focused, so that setMyKeyListener method can
         //listen for shift/control KeyEvent
         table.requestFocus();
    //     System.out.println("myRowCount = " + myRowCount);
         if( getShiftKeyDown() ){
         table.clearSelection();
         table.setRowSelectionInterval(0,myRowCount-1);
         table.setColumnSelectionInterval(selectedColIndex,selectedColIndex);
         if(firstSelectedColIndex > -1) {
              table.addColumnSelectionInterval(firstSelectedColIndex, selectedColIndex);
              firstSelectedColIndex = -1;//restore to -1
         } else if( getCtrlKeyDown() ) {
         table.addRowSelectionInterval(0,myRowCount-1);
         table.addColumnSelectionInterval(selectedColIndex,selectedColIndex);
         } else {
         table.clearSelection();
         table.setRowSelectionInterval(0,myRowCount-1);
         table.setColumnSelectionInterval(selectedColIndex,selectedColIndex);
         if(DEBUG) System.out.println("shiftKeyDown = " + shiftKeyDown
              +";"+" ctrlKeyDown = " + ctrlKeyDown);     
         //saves the first selected column index
         firstSelectedColIndex = selectedColIndex;
    * MouseAdapter implemenation.
    * mousePressed: sets the select-all functionality
    * when upper left corner label of the table is clicked
    * Guanglin Du, 2002/09/18
    public void mousePressed(MouseEvent e) {    
         if(DEBUG) System.out.println("Select all");
         stopLatestCellEditing();//To save the data in editing
         getMyTable().selectAll();
    * Triggers the latest <code>ActionEvent</code> in a table cell to save
    * the latest data. Or, the newly input data will not be stored into the table
    * model and cannot be retrieved.
    public void stopLatestCellEditing() {
    int editingRow = getMyTable().getEditingRow();
    int editingCol = getMyTable().getEditingColumn();
    if (editingRow != -1 && editingCol != -1){
         TableCellEditor cellEditor =
         getMyTable().getCellEditor(editingRow, editingCol);
         cellEditor.stopCellEditing();
    Here is how you can use it in your coding(where myTable is a JTable instance you create):
         /* Adds TableSelectionAdapter to enable all kinds of selection action. */
         TableSelectionAdapter tableSelect = new TableSelectionAdapter(myTable);     

  • Is it possible to diable multiple selections in JTable and JList?

    as the title states, is it possible to disable multiple selections? how to prevent user from using ctrl or shift keys to select multiple rows?

    Use the setSelectionMode(ListSelectionModel.SINGLE_SELECTION ) for your JList / JTable.

  • Multiple selection of rows and delete the same

    hi how can we select the multiple rows in a table and delete the same.
    if i have 3 rows i have to select 2 rows and if i press the delete button the selected rows should be deleted.
    Can any one help me .
    Thanks
    Badri

    hi
    in the layout of the screen u might have dragged and dropped the table control
    double click on it u will get attributes screen in that u select MULTIPLE under Line-Selection
    under attributes tab.
    the internal table in table control must be like
    data : begin of itab occurs 0,
             empno type .......,
             empname......,
             empcity.....,
             check(1), " for tab selection"
             end of itab.
    data : itab1 like itab occurs 0 with header line.
    in the attributes screen of the table control
    pass the value ITAB-CHECK to the field W/SELECTION
    in SE51
    PBO
    Module_status_0800
    loop with control table_control_name.
    module_fill_tcontrol.
    endloop.
    PAI
    Module_user_command_0800
    loop with control table_control_name.
    module_read_tcontrol.
    endloop.
    in se38
    Module_fill_tcontrol. 
    endmodule.
    Module_read_tcontrol.
    READ TABLE itab1 INDEX control-current_line.
      IF sy-subrc EQ 0.
        MODIFY itab1 FROM itab  INDEX control-current_line.
      ELSE.
        MOVE-CORRESPONDING itab TO itab1.
        APPEND itab1.
        CLEAR itab1.
      ENDIF.
    endmodule.
    module_user_command.
    case sy-ucomm.
    WHEN 'DELE'.
          DELETE itab1 WHERE check = 'X'.
    endcase.
    endmodule.
    Regards
    Murali.M

  • Multiple selection of WBS  for CJIC Transaction

    Hi,
    Any one please can you let me know is there any way for Multiple selection of WBS elements in CJIC Transaction.I implemented Note 635711, but it is adding field at Additional Selection not in Selection screen. Even the output iam getting is different from Selection screen WBS element.
    Waiting for your responses.
    Thanks,
    Anitha A

    hi
    Check this link it might give hint, same you can try in wd java.
    http://www.roseindia.net/jsp/file_upload/uploadingMultipleFiles.shtml
    As in above code separate file up-loader is used for each file.
    I know you might be looking;like lotus or outlook copy all attachment is such a way.
    Edited by: Yogesh Galphade on Mar 22, 2011 7:51 PM

  • Any way to select all emails for delete with one touch?

    The only time I really need to see emails on my iPhone is when I am away from home. When I am home, and receive a huge number of emails on my iMac, I also receive the same ones on my iPhone.
    I review them on the iMac, and then have to delete them from the iPhone. I go into the account on the iPhone and touch edit, but then have to scroll and check off each one so I can delete them.
    Is there any way to "select all" instead of checking off each one?

    The iPhone's mail client does not synchronize with the incoming mail server for a POP account. The iPhone's mail client is no different in this regard from accessing a POP account with an email client on your computer. You have an option to remove messages from the server when downloaded for a POP account with the iPhone's mail client as is available with an email client used on your computer to access a POP account.
    All server stored mailboxes with an IMAP account are kept synchronized with the server automatically with each email client used to access the account including with the iPhone's mail client. A POP account is not synchronized with the server - not with the iPhone's mail client or with an email client on your computer.

  • How to get the path of the selected Jtree node for deletion purpose

    I had one Jtree which show the file structure of the system now i want to get the functionality like when i right click on the node , it should be delete and the file also deleted from my system, for that how can i get the path of that component
    i had used
    TreePath path = tree.getPathForLocation(loc.x, loc.y);
    but it gives the array of objects as (from sop)=> [My Computer, C:\, C:\ANT_HOME, C:\ANT_HOME\lib, C:\ANT_HOME\lib\ant-1.7.0.pom.md5]
    i want its last path element how can i get it ?

    Call getLastSelectedPathComponent() on the tree.

  • Multiple Selection of files for File Upload

    HI,
    Can we upload Multiple files at a time using File Upload option?
    Regards,
    Raju

    hi
    Check this link it might give hint, same you can try in wd java.
    http://www.roseindia.net/jsp/file_upload/uploadingMultipleFiles.shtml
    As in above code separate file up-loader is used for each file.
    I know you might be looking;like lotus or outlook copy all attachment is such a way.
    Edited by: Yogesh Galphade on Mar 22, 2011 7:51 PM

  • Logic for Deletion of a row is not reflecting in DEV instance

    Hi ,
    I have a method in AM attached to a Search screen which has logic to delete rows from 3 different VOs.
    1. VO for selecting the rows from Details table.
    2. VO for selecting the rows from Master table.
    3. VO for holding the rows of results tables.
    The results table displays rows from both master table and details table. On selecting a row for delete in results table , the remove() method is being called to remove rows from the three VOs in the same order mentioned above.
    This logic works perfectly in my local setup. The commit was initially not getting recognized. So , we included the line "JDBC\:processEscapes=true" after which delete and commit started working fine in my local setup.
    But the same code does not work in the DEV instance. Can anyone please suggest what can be done in such a case.
    Thanks,
    Chandrika

    Thanks for your reply,
    As we did registration again now for the problematic server autoreaction method is now visible in RZ20
    But it is not picking up the alert for the scenarios. Also found other 2 server is also giving error while connection test below is screen shot.
    I checked the log file. Foundthe agent lock is not getting updated.
    and error log details
    [Thr 4396]
    Fri Jun 27 08:12:44 2014
    INFO: Register central system PSM.
    INFO: Register central system: System PSM already registered as central system. Trying to update...
    ERROR: Register central system: cannot stop agent, because the agent is restarting.
    Fri Jun 27 08:44:56 2014
    INFO: Unregister central system PSM.
    ERROR: Unregister central system: cannot stop agent, because the agent is restarting.
    [Thr 7084]
    Fri Jun 27 08:52:07 2014
    INFO: Register central system PSM.
    INFO: Register central system: System PSM already registered as central system. Trying to update...
    ERROR: Register central system: cannot stop agent, because the agent is restarting.
    Can you please check and let me know the fix to resolve the error.

  • Regarding multiple selection

    Hi experts
         I had a problem in development that i needed a UI element in which multiple selection is possible for data coming from WSDL. if their is any solution for this problem in Webdynpro 7.0 or any version will be appreciated.
    Regards
    Ruderdev.

    Hi rudradev,
    You can use the table UI element. If you want the multi slection on the table then set the <b>selection cardinality</b> of the node that you have bounded to table to<b> 0..n</b>.This works in Webdynpro 7.0 .
    Regards,
    Jhansi

  • Downloaded Mountain Lion and now not able to select multiple email messages at a time for deletion what gives?

    Downloaded ML last night now one little glitch seems to be that I cannot select multiple messages at a time to delete. With the massive amount of email I receive, this is a problem. Cannot seem to find any simple fixes in preferences. Any ideas?

    you could use one hand to do this, before ML. select one email and drag up/down with the cursor to select more. selecting/shift key is the normal multiple selection operation. that's two handed.
    if there is empty space at the bottom, it works.
    i did submit this through the feedback process. i hope the functionality returns.

  • How do i delete multiple rows in JTable

    hello
    how i delete multiple rows in JTable
    when i selected multiple rows from the jtable and delete its give the error ArrayIndexOutOfBoundException
    e.g.
    int rows[]=jtable.getSelectedRows();
    for(int i=0;i<rows.length;i++)
    DefaultTableModel model=(DefaultTableModel)jtable.getModel();
    model.removeRow(rows);
    like this
    please help me
    meraj

    You are trying to remove the rows an equal times to the amount of rows selected.
    You should remove one row at a time:
    model.removeRow(rows);
    Change your code into this.
    for(int i=0;i<rows.length;i++)
    DefaultTableModel model=(DefaultTableModel)jtable.getModel();
    model.removeRow(rows[i]);

  • Can't delete multiple selected items in List or Library

    I am experiencing quirky behavior when attempting to delete multiple selected items from a library or list. I select a few items via check box for each item I would like to delete. Then I click the delete button in the ribbon, and all I get is "Deleting...",
    but no page refresh and the items are not deleted. However if I access the same list or library via the App server and select a few items, then hit delete, the page refreshes and the items are deleted.
    So I consulted the Logs and compared the Web Server vs App Server, and the there is a lot of cryptic entries. The few lines that stands out most to me is the App server is:
    ConnectionString: 'Data Source=database;Initial Catalog=Content;Integrated Security=True;Enlist=False;Asynchronous Processing=False;Connect Timeout=15'   
    ConnectionState: Closed ConnectionTimeout: 15
    In fireItemEvent(), for list Building Locations, and item: 1
    In fireSyncItemEvent(), calling ExecuteItemEventReceivers()
    Calling ExecuteItemEventReceivers() for list 0f773535-3b22-4c29-97f1-fd2b70b50dd3 on item 1
    Entering monitored scope (Event Receiver (Microsoft.SharePoint.Publishing, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, Microsoft.SharePoint.Publishing.Internal.PublishingWebEventReceiver))
    Releasing SPRequest with allocation Id {FE9A45A8-C042-4223-8FCC-4BD873C93885}
    PublishingWebEventReceiver:ItemDeleting: item 
    These calls are not in the web server log.
    The list I was doing the delete action on was "Building Locations". We are using claims based authentication
    Thanks for any insight or thoughts.
    Brandon

    I confirmed that there is no rewrite tags in either web config (app or web).
    I did download fiddler, and when I try and delete on the web front end I get:
    It tries to access the URL https://mysite/_layouts/_vti_bin/client.svc/processQuery
    Then it sends me here since I have been denied
    <html><head><title>Object moved</title></head><body>
    <h2>Object moved to <a href="https://mysite/_layouts/AccessDenied.aspx">here</a>.</h2>
    </body></html>
    The app server goes to
    http://mysite/_layouts/_vti_bin/client.svc/processQuery doesn't get denied and deletes the items.

Maybe you are looking for

  • Dip To White Transition

    hi i make a movie with "PiP" and i would like to apply a " Dip to White" transition which will affect only on the "PiP". i really cant find a way to apply it to the "PiP". thanks for helping

  • Ringtones for iTunes

    Did apple fix the loophole in creating ringtones using iTunes only or am I missing something? (The process involved creating a song into mp3 format and changing the file to .m4r)

  • How do I attach a pic to a reply email?

    Trying to attach a picture to a reply email using iPad.  How can I do that?

  • IPod Cover.. which one should I get?

    I've had my 30GB Black Video iPod for almost a week now, and it barely has any scratches, but I still want to get a case/screen-protector so it won't get anymore. I heard that the iSkins are good (they look good too), and they just came out with new

  • I Insert a .MPG Video File, but it does not work in Director... any Xtra is needed?

    Hi. I have a .MPG Video File that i can see in other players fine, but when i insert it into a Director movie, it doesn't work, I don´t know if i need any Xtra or something. it´s my homework to my University. I need help. Thanks.