How to delete items selected in a JList?

Ahoy,
I hava made a Multiple selection list (two list: one for
the items that might be selected and another one
for the selected items). How can I delete the (faultly) selected items in the second list?
Thanx,
// create function button
copy = new JButton( ">>" );
delete = new JButton ( "<<");
copy.addActionListener(
new ActionListener() {
public void actionPerformed( ActionEvent e )
// place selected values in functionList
copyList.setListData(
functionList.getSelectedValues() );     
delete.addActionListener(
new ActionListener() {
public void actionPerformed( ActionEvent e )
// delete selected items from copyList
);

You must get the selected item and remove from the model...
delete.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int si = list.getSelectedIndex(); //get the index of the item selected
if (si > -1) {   //to validate that be selected
listModel.removeElementAt(si);  //remove from the listmodel
modifyTextField.setText("");  
});in this url you can see a complete sample..
http://www.esus.com/javaindex/j2se/jdk1.2/javaxswing/atomiccontrols/jlist/addtojlist.html

Similar Messages

  • How to delete items in transport request

    How to delete items in transport request.  I have quite a lot data to be deleted.
    I click on TR5001. Then click to drill down to Table contents
       C001 
                Data A1
                Data A2
                Data B1
                Data B2
    Placed my cursor on Data A1 and tried deleting Data A1 by clicking on the item and right click then select delete but not able to delete with message "Message no. TK705, A request, task or object could not be deleted because the cursor was not positioned correctly".  . 
    Any clue to the error and any recommded solution?
    I just need to transport Data A2, Data B1 & Data B2. 
    Regards
    PSK

    Hi There,
    I dont have access to SAP as of now, Can you please reffer to these links and give feedback,
    [cursor Page|http://books.google.co.in/books?id=ASekwAiAXdMC&pg=PA250&lpg=PA250&dq=Positionthecursoronarequest,task,orobjectSAPtransport&source=bl&ots=BS7c1uNH0z&sig=dQZNp7UuXvqyHT9-otTbip8iF8U&hl=en&ei=_NBESr7CDsmGkAXX8MmsDw&sa=X&oi=book_result&ct=result&resnum=1]
    [SAP help|http://help.sap.com/saphelp_sm32/helpdata/EN/b6/b40613a44411d1846d0000e8a57770/content.htm]
    Thanks,
    Raja

  • How to delete the selected rows in a JTable on pressing a button?

    How to delete the selected rows in a JTable on pressing a button?

    You are right. I did the same.
    Following is the code where some of them might find it useful in future.
    jTable1.selectAll();
    int[] array = jTable1.getSelectedRows();
    for(int i=array.length-1;i>=0;i--)
    DefaultTableModel model = (DefaultTableModel)jTable1.getModel();
    model.removeRow(i);
    }

  • How to delete items in download queue on server side?

    how to delete items in download queue on server side?

    We are fellow users here on these user-to-user forums, you're not talking to iTunes Support nor Apple. If you've tried deleting them and they keep re-appearing in your downloads then you will need to try contacting iTunes Support to get them removed : http://www.apple.com/support/itunes/contact/

  • How do i pass selected value of JList in one frame to other frame?

    hai everybody,
    In my application where i m using swing as GUI in that i require selected value of Jlist in one frame to other frame ..
    Since i need the previous frame jlist selected value for my application.
    How this can be done
    Help me pa
    Thanx in advance

    You need to post your Short, Self-Contained, Compilable Example or SSCCE if you need further help.

  • How to Delete a Selection

    I am having trouble with what something that seems like it should be simple. I simply want to delete a selection that I've made with the quick selection tool. How can this be accomplished?

    NM, I was in the wrong layer that's why the delete key wasn't working.

  • Attempting to Get Specific Items Selected from a JList

    Hello all, back again...
    I'm working on a simple interface that can run an SQL query with specific settings, and these settings can be altered by choosing one or multiple options from a JList to the side of the table that displays the results. My problem is, currently, not being able to figure out how to get the accursed thing to tell me what items in the JList are selected!
    I've tried using:
    int multiselect[] = cmbSystems.getSelectedIndices();...but it inevitably returns an array with a size of 1. Frustrating. I know I'm missing something, but I have no idea what. What am I doing wrong? Thanks!
    ~ Matt

    Mystrunner wrote:
    Hmm, okay... give me a bit to figure that out, and I will. :)Sure. Your SSCCE should probably only consist of a JList that prints out the selected items when the selection changes, or something like that. I would bet that you figure out what's going wrong in the process of boiling your code down to the SSCCE.

  • Setting a limit on number of items selected in a JList

    hi guys,
    I have a JList in my swing application. The default Selection mode is Multiple-interval Selection.
    But actually i want to select a maximum of only 3 items at a time from the list, so can anyone help how to fine tune this selection criteria.
    Thanks,
    vishal

    The 'proper' way would be to implement ListSelectionModel (either directly or through DefaultListSelectionModel) and implement the functionality you want. You will need to override the setSelection methods (i.e. addSelectionInterval, setSelectionInterval etc) with something like:
    public void setSelectionInterval(int index0, int index1) {
       if ((index1 - index0) < maxSelectionCount) {
          super.setSelectionInterval(index0, index1);
    // ... etcYou will need to decide what you want to happen when a user tries to select a fourth item, you could either ignore the request (probably the easiest) or you could deselect one of their other choices.
    As a side note, I dont think that limiting the number of selections on a list is a very intuaive interface design. I don't know what the ideal solution would be, maybe a collection of three combo boxes or something like that.

  • How to delete a selected row from adf table

    Hi
    I am using a ADF Table to get data from the database, i need to select a specific row and then delete it how to get
    this done.
    Thanks in Advance.

    Or try this code:
    In your backing bean:
        public void deleteRows(ActionEvent actionEvent) {
            ((AppModuleImpl)getApplicationModuleForDataControl()).deleteRowEmp();
        public static Object resolveExpression(String expression)
                try
                    FacesContext facesContext = FacesContext.getCurrentInstance();
                    Application app = facesContext.getApplication();
                    ExpressionFactory elFactory = app.getExpressionFactory();
                    ELContext elContext = facesContext.getELContext();
                    ValueExpression valueExp =
                        elFactory.createValueExpression(elContext, expression, Object.class);
                    return valueExp.getValue(elContext);
                catch (Exception e)
                   ;// log you message here
                return null;
             * Get application module for an application module data control by name.
             * @param name application module data control name
             * @return ApplicationModule
            public static ApplicationModule getApplicationModuleForDataControl()
                return (ApplicationModule) resolveExpression("#{data.AppModuleDataControl.dataProvider}");
            }In your AppmoduleImpl:
        public void deleteRowEmp(){
            this.getEmpView1().removeCurrentRow();
            this.getDBTransaction().commit();
        }And another option is to expose the appmodule method as a client and bind to the jspx as a button.

  • How to Delete Item from Front Row?

    Someone sent me a short imovie project and it was automatically downloaded to my "Download" folder. When I opened Front Row, the project name it's right under "Movies" along with "iTunes Top Movies", "Theatrical Trailers" and "Movie Folder".
    I then moved the project file from "Download" to another folder created under my "Movie" folder. When I went to Front Row again, the original project was still under the list in Movies, now it's also in "Movies Folder". So basically it's showing up twice in Front Row in different places.
    I see that once I play the movie from my Movies folder directly from the folder, it's automatically set to Music/iTunes/iTunes Media/Movies. So it's showing up in Front Row via iTunes, and it's also showing in Front Row via my Movies Folder.
    I just want to organize Front Row so that I don't have a long list of projects immediately under "Movies" in Front Row. I want these projects to neatly go in one personal movie folder only.
    Is there a way to reorganize the items list in Front Row?
    How do I delete the item that's originally placed under "Movies" in Front Row?

    Assets are organized in various apps - primarily iTunes for most of us.
    That said, you may benefit from this series:
    http://www.macnewsworld.com/story/59317.html

  • How to delete the selected rows with a condition in alv

    dear all,
    i am using the code in object oriented alv.
    WHEN 'DEL'.
    PERFORM delete_rows.
    FORM delete_rows.
    DATA : lv_rows LIKE lvc_s_row.
    data : wa_ROWs like LVC_S_ROW.
    FREE : gt_rows.
    CALL METHOD alv_grid->get_selected_rows
    IMPORTING
    et_index_rows = gt_rows.
    IF gt_rows[] IS INITIAL.
    MESSAGE s000 WITH text-046.
    EXIT.
    ENDIF.
    loop at gt_rows into wa_ROWs .
    if sy-tabix ne 1.
    wa_ROWs-INDEX = wa_ROWs-INDEX - ( sy-tabix - 1 ).
    endif.
    delete gt_sim INDEX wa_ROWs-INDEX .
    endloop.
    the rows to be deleted from int.tab gt_sim not in the alv display.
    all the rows should not be deleted if one of the field in gt_sim eq 'R'.
    how to check this condition

    dear jayanthi,
            ok if i am coding like that as u mentioned ,
              it will exit the loop when first time the field value is 'R'.
      if any of  the selected rows contains  field value 'R'. it shold not delete all the selected rows.
    as u suggested it will not delete after first time the field value is r.
    i am deleting it by tab index so,
    suppose if i am selecting the row without field value R say its tabix is 1.
      the next row with tabix 2 with field value R.
      it deletes the first row and exits , it should not delete the first row also.

  • How to delete items in download queue

    I've got a number of TV shows in my download queue that I decided against purchasing.  They have never been downloaded.  I delete them manually from the queue, but they keep reappearing.  How can I delete these items permanently?

    Sorry, but I find it very annoying that you can't cancel  something you downloaded when you got it for free (for example, the free songs, books, and apps that Starbucks offers). I  don't mind downloading the songs because they are short, but  when I  download a free TV show and then it tells me it's going to take 4 hours to download because it's 1.4 gigabytes, I want to be able to cancel the download permanently. As it stands now, it keeps coming back on the queue. There should be an option to cancel the download permanently.  I have called Apple  once already to discontinue a long download and they helped, but I don't think  Apple customers  should be required to call them to cancel a download, nor should we be required to wait 4 hours for a download to complete before deleting it.

  • How to delete items in cloud

    How do I delete old videos etc in cloud?

    your self-recorded iOS videos are not accesible . Neiter to delete them nor to watch them..  they are just part of the full iOS backup at once. To delete your backup ( which is a bad idea ) , open Lions icloud preference in Systemsettings, click on the space indicator "manage". From there you can delete cloud data.
    If you thought of purchased itunes videos : they are in your purchased items list and do not take up your space. Apple holds them for you.

  • Home folder on Skype - how to delete items

    My home folder on skype shows a lot of titles of tunes with dancing music notes - when I click on them My profile page pops up. How do I get rid of thes items ??

    If you switched always show bookmarks bar to off, you should not be seeing any bookmarks in the bookmarks bar. If you want to keep the bookmarks bar, but remove some of the bookmarks in it .....
    Tap the bookmarks icon and then tap Bookmarks bar. Tap Edit in the upper right corner of that window, tap the red line in a circle icon to the left of the bookmark, then tap Delete when it pops up. Or just swipe across the bookmark and the delete button pops up,
    Tap done when you are finished.

  • How to delete items from itunes library but not from computer

    I was wondering if there is a way to remove items from my itunes library but still keep them on my computer in case I want to put them back in the library later. For instance, I bought the first season of Desperate Housewives, which takes up about 4.5 GB, and since I have the 30 GB ipod and lots of personally ripped DVDs, I'm running out of room. But it seems a waste to trash the files, since I paid for the show. I know I should back up the files to an external source anyway, and I've done that with my purchased music, but I don't have a DVD burner, and I'm not sure how many CDs it would take to back up the show. And I don't want to manually update the ipod because I think it's much easier to just plug it in and let it do its thing. Any suggestions/help would be appreciated. Thanks.

    Go to that File(s) and right-Click to Remove; then it will ask you if you want to send it to the Recyle bin or Keep Files on your computer; Say Keep Files on your computer and should be fine.

Maybe you are looking for