Delete Selected JList Item on Pressing Delete Key

Hi,
I have to delete selected JList item ((in JFrame using java Swing) after pressing Delete key. Please provide me code for this.
Thanks
Nitin

Again read the Swing tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/components/list.html]How to Use Lists and [url http://java.sun.com/docs/books/tutorial/uiswing/misc/keybinding.html]How to Use Key Bindings.
Are you sensing a common theme here? Do some reading on your own. The tutorial has most of the information you need.

Similar Messages

  • How to active menu item by press Alt key

    Hi everyone,
    I don't know how can i active jmenu bar by pressing Alt key first, and press another key ( for exp. press 'F' go to File menu), they are not at the same by holding Alt key.
    Thanks for help in advance.

    I still didn't get it, would you like give me some details.
    How do i make the ALT key select it (but not open it).
    By pressing the "F' key, the "File "menu selected should be opened.

  • Select JList item on Mouse over Event

    Hoi All,
    I am trying to find a way to select the items in a JList when the mouse is moved over the item.
    Any help is appreciated
    Kind Regrads ,
    Werns

    Hey J�rg,
    I solvd the problem by using the following method:
      public void dragOver(DropTargetDragEvent dtde) {
                jListLocalLibrary.setSelectedIndex(jListLocalLibrary.locationToIndex(dtde.getLocation()));
            }What i'm doing is creating a digital library so the owner of a book kan move a book between shelves so you have one JList that shows books of a shelf and a nother JList that shows the available shelves the JList is not enabled to accomodate multiple selection thus the derection from which the JList is approcahed does not matter.
    If you need more info just drop me a reply and i'll be happy to share.

  • Selecting jList items

    Hi!
    I'm developing a image browser app using JList. I'm having problems with a contextual popup menu. When I click on an image from the JList I show the popup with some options related to the image (delete,
    paste, etc ...),
    But when I click on an empty zone in the JList, the last item gets selected and the same popup gets shown even though I didn't click any item.
    1) what should i do so that no item in the jlist is selected when i click in its empty zones
    2) how do i make a different set of menuitems be enabled or disabled which i click on the empty zones
    Thanks in adavance
    kalpana

    1) what should i do so that no item in the jlist is sselected when i click in its empty zonesYou may have to override JList's locationToIndex(Point p) method so that it returns -1 (or probably the currently selected index) when the point is not located in any of the list items. I believe by default, this selects the closets index to the point.
    2) how do i make a different set of menuitems be enabled or disabled which i click on the empty zonesYou have to provide some sort of manager class or interface where the popup menu can go to obtain the state of the image in the list, and enable or disable the menuItems as necessary.
    ICE

  • Selecting JList item with the spacebar

    i have a class that extends JList, and my JList is a list of checkboxes. I would like to move to a checkbox with the arrow keys, check a checkbox with the spacebar, or uncheck it if the spacebar is pressed again. it should only select/deselect the certain checkbox and have no effect on the others. is there a way to do this?
    thanks :)

    okay, i figured this out myself... not too hard :) if there is a more efficient way, let me know.
    addKeyListener(new KeyListener() {
                  public void keyPressed(KeyEvent e) {
                   if(e.getKeyCode() == KeyEvent.VK_SPACE){
                        int index = getLeadSelectionIndex();
                        if (index != -1) {
                                     JCheckBox checkbox = (JCheckBox)getModel().getElementAt(index);
                                     checkbox.setSelected(!checkbox.isSelected());
                                     checkbox.setBackground(checkbox.isSelected() ? getSelectionBackground() : Color.white);
                                     repaint();
                  public void keyReleased(KeyEvent e){}
                  public void keyTyped(KeyEvent e){}
            });

  • Select Outbound Line by Pressing Line Key on Phone

    I have an Elastix installation. I have two Cisco spa525G2 phones and I need to setup the following on the phone and was hoping someone could help me or point me in the right direction. I've been reading the Cisco documentation, but I am getting more confused by the minute. The closest I could get was this from the Cisco forums...
    "If you choose to deploy a SPA400 in an Asterisk environment, you will need to define which SPA400 line to use. This document describes how to accomplish this.
    exten => 6XXXXXXXX,1,Dial(SIP/L2{EXTEN},20)
    By setting Ln string before an extension in the INVITE, where "n" is the line number on the SPA400, one can choose which line to route the call to (in the previous example it goes to Line 2). If not using Ln, the call will end up on first available line (the SPA400 is then treated like a trunk). This has been tested to work with 1.1.2.2 SPA400 firwmare."
    I need the user to be able to press one of the Line Key buttons, then dial a phone number which will then route the call out the correct outbound route based on the line key pressed. I already have the trunks and Outbound Routes setup and working by dialing "9" or "5" before the number. I just need to setup the phones Line Key buttons correctly.
    I would greatly appreciate any help you could provide.
    Thanks in advance!
    Spencer

    Just a few updates, I still have the issue, but it also happens in Outlook sometimes (not very often) when I write emails. So it might not be linked to Adobe Reader at all.
    Is there a common composant that both Outlook and Adobe use to select text?
    Additional information: It's not just the text selection I cannot do in Adobe Reader, it's everything that need the mouse to move while left button is pressed. For example, I cannot move the separator between bookmarks and document.
    So could it be an issue with the mouse/keypad driver (from Dell)?
    I'm just dumping information in case someone else has the same issue, hopefully google will lead them here and they will know they are not alone.

  • Double click for JList items selection

    I would like to select JList items only by double clicking on them. I can write a mouse listener for detecting double clicks by my own (and handle it afterwards), by please tell me how to turn the default behavior off (selecting items by clicking one time).
    Thanks in advance
    Marek

    I would like to select JList items only by double clicking on them. Well the standard is to select or highlight on a mouseClick or by using the arrow keys on the keyboard.
    Then once you have a selected item you can perform and Action on the item by double clicking or by using the enter key. Remember you should always be able to use either the keyboard or the mouse to perform any given function.
    This posting shows my solution for the above scenario:
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=626866

  • Dynamically changing size of JList items?

    Hello!
    I'm working on an application which kind of revolves around a JList with a custom ListCellRenderer. Now, it all works rather good as it is, but I want the selected JList item to show more detailed information about the selected value, and thus I need it to be bigger then the not selected items. The thing is that no matter what I do I can't seem to make the JList adopt to the new size of the selected item, which results in only half of the stuff in the selected item being shown.
    Is there any way to do this it would be great! (I bet there is some really simple way which I have simply overlooked.)
    And, fyi: The component returned by getListCellRendererComponent is a JPanel which consists of three JLabels using a GridLayout. The selected component is generally the same, but with an extra row in the GridLayout.
    Any help/suggestions will be greatly appreceated!
    Yours, Jiddo.

    I have tried with a couple of different layout managers, and none of them (except for this one) seems to offer me the layout I need. Also, I have tried making it return different instances depending on if it is selected or not. The non-selected one has only one row in the layout while the selected has two. Here is a screenshot of how it looks:
    http://img211.imageshack.us/img211/2779/jlistes1.jpg
    Yours, Jiddo.

  • Project deleted in iPhoto 11 ver. 9.1.1 After spending three months building a twenty six page Book Project in iPhoto i added a page and later decided to delete the page. I selected the page, pressed the delete key and confirmed the delete dialog box ( i

    Project deleted in iPhoto 11 ver. 9.1.1
    After spending three months building a twenty six page Book Project in iPhoto i added a page and later decided to delete the page. I selected the page, pressed the delete key and confirmed the delete dialog box ( i didn't read, dummy) by pressing the delete button. The whole project was gone, the undo menu was grayed out and there was nothing in the iPhoto trash about my Book.
    Surly I can find this if I knew the path to find the project in a library on a back column I have of my hard drive.. Could anyone help me?

    Sorry I'm having a hard time getting this.
    If I go to my hard drive BIGMAC>Library>Application Support>iPhoto>the only thing in this folder is Themes.
    However, when I "Get Info" it's 580MB for 24,421 items. iPhoto says I have 35,977 photos. I would think the database would be into the GB for this many photos.
    If I go to BIGMAC>system>Library>I find nothing about iPhoto
    Is the iPhoto file in the Application Support the one I need to replace with my backup?
    Thanks so much for your help.
    Jack

  • Strange items deletion in various applications as if the Delete key being pressed.

    I work with a T420 laptop docked in a docking station.
    The following strange phenomenon is happaning:
    Occasionally, Items are being deleted or attempt to be deleted in various applications as if the Delete key is being pressed constantly.
    Examples:
    1. The Outlook window is open, left mouse click on the Inbox folder results in all emails being deleted.
    2. Explorer window is open, left mouse click on one of the files or folder results in attemp to delete the file or folder. Clicking 'NO' results in an endless loop of attempt to delete.
    3. Google window is open (IE), clicking on one of the letters in the search box, results in this letter being deleted.
    4. Open Task manager, results in attempt to delete the first task in row.
    When docked out the laptop from its station, this strange behavior stopped.
    Needles to say, that I replaced the external keyboard and the docking station itself, but it did not help.
    HAS ANYONE ENCOUNTERED SUCH A PROBLEM? What do I do?!

    I am having a similar issue that I can consistently recreate. I was finding that emails were "randomly" getting deleted from various folders. It was driving me crazy! I keep my Outlook inbox fairly well organized in that I keep emails in there if they require further action. I don't keep my Deleted folder organized however, so I was getting chunks of emails going from my Inbox to my Deleted items folder and it became very difficult to find all of the deleted emails that I still needed to action..... Here is how I can recreate this:
    Laptop is off of the docking station and open. Outlook has focus with an email highlighted in my inbox. I close the lid and place the laptop onto the docking station. The email that had focus is now in the deleted folder. Again, I can recreate this virtually every time. Please help!

  • I am trying to free up some room on my touch and am unable to delete any songs or books from the listing.  With iTumes open and my touch listed I open the touch.  I then select the items I want to delete from the touch and press the delete button.

    I am trying to free up some room on my touch and am unable to delete any songs or books from the listing.  With iTumes open and my touch listed I open the touch.  I then select the items I want to delete from the touch and press the delete button.  Nothing happens.  I have also tried to right click on the item, but a delete option is not listed.  What do I need to do to get rid of some books?

    Open itunes, connect ipod, go to each tab, select what you want to be on the ipod, sync

  • Key pressed in Jlist and selecting the item of key list accordingly

    Hi,
    I have a JList with the items in sorted order.Now I want that if a person presses any key (say K) then the first item starting with K should be selected.Hmmm I can do it by addding a key listener to the list and cheking all the items in the list ,by traversing through the whole lenght of JList and selecting the item if it starts with the character of the key pressed.
    But i was thinking if there is any better way to do that?
    Regards Amin

    see bugid: 4654916 - it does say that the the
    scrolling for the JList should now work with keyboard
    selection.I have the same problem. Thanx for the hint with the bugid. Saw a good workaround there with a simple subclass of JList. Works for me although it is annoying to subclass JList all the time. The bug seems not to be fixed in the 1.4.1 JDK.
    Andreas

  • How to delete a row in ADF Table by pressing "Delete" Key

    I want to delete a row in my ADF table by pressing the "Delete" key..How can i achieve it?

    hai ,
    I write clientListener and ServerListener..But in the script i printed the event.getKeyCode() ...*When i press Delete Key or EnterKey ,it is not printing the value*..
    The code i write is pasted below..
    In the code backing_Comm is my backingbean..Is there any problem in the code that i had written?I want to delete a selected row from my table using keypress Event...pls advice..
    <script type="text/javascript">
    onPressDeleteKey=function(event){
    alert(event.getKeyCode()); // *Here i am not getting the alert, when i press Delete Key or Enter Key..But getting alert when i press A- Z or 1 - 0*
    if(event.getKeyCode()==AdfKeyStroke.ENTER_KEY) {
    var source = event.getSource();
    AdfCustomEvent.queue(source,performDeleteOnPress,{},false);
    </script>
    <*af:table* value="#{bindings.ComMastVO.collectionModel}"
    var="row"
    rows="#{bindings.ComMastVO.rangeSize}"
    emptyText="#{bindings.ComMastVO.viewable ? 'No rows yet.' : 'Access Denied.'}"
    fetchSize="#{bindings.CompMastVO.rangeSize}"
    rowSelection="single"
    id="tblCom"
    columnStretching="last" inlineStyle="width:100%;"
    width="273"
    selectionListener="#{backing_Comm.rowSelectCom}"
    binding="#{backing_Comm.tblCom}"
    clientComponent="true" >
    <*af:column* sortProperty="Com" sortable="true">
    <*af:inputText* value="#{row.bindings.Com.inputValue}"
    label="#{bindings.ComMastVO.hints.Com.label}"
    required="#{bindings.ComMastVO.hints.Com.mandatory}"
    columns="150"
    maximumLength="#{bindings.ComMastVO.hints.Com.precision}"
    shortDesc="#{bindings.ComMastVO.hints.Com.tooltip}">
    valueChangeListener="#{backing_Comm.onValueChange}"
    autoSubmit="true" >
    <f:validator binding="#{row.bindings.Com.validator}"/>
    *</af:inputText>*
    *<af:serverListener type="performDeleteOnPress"*
    *method="#{backing_Comm.goDeleteCurrentRow}"/>*
    </af:column>
    *<af:clientListener type="keyPress"*
    *method="onPressDeleteKey"/>*
    </af:table>
    =================================================
    anybody pls help??
    Edited by: Briston Thomas on Jun 3, 2009 2:25 AM

  • ALV GRID Problem when delete key is pressed from keyboard

    I have created a ALV Grid using cl_gui_alv_grid class
    I this I made one field editable based on some conditions
    and used SEL_MODE as 'A' ( i tried 'D' too) in the LAYOUT Settings
    When I select the records and press the DELETE key from keyboard
    the records are getting deleted, and i am not able to catch this action
    in the debug mode
    (FYI: I have written my own set of code for delete row in the USER COMMAND EVENT which is not getting triggered in this case )
    Can any body help me with this

    have you used this to trigger the event
    SET HANDLER W_EVENT_RECEIVER->HANDLE_USER_COMMAND FOR W_GRID

  • Please Help!! I deleted the folder System en Macintosh HD and now when i on my mac it says Disk Error Press Any  Key To Restart Please HELP !!

    I deleted the folder System en Macintosh HD and now when i on my mac it says Disk Error Press Any  Key To Restart Please HELP !!

    Reinstall Mac OS X.
    (59450)

Maybe you are looking for

  • Is it possible to rollback patch 9206876 - UNABLE TO IMPORT INTERCOMPANY AP

    Hi All, DB:11.1.0.7 Oracle Apps: 12.1.1 OS:Linux 86x64 Red Hat Is it possible to rollback patch 9206876 - UNABLE TO IMPORT INTERCOMPANY AP INVOICES. What are the patches those can be rolled back in EBS R12? Thanks for your time! Regards,

  • "Install Windows 7 or later version" check box not showing up in Boot Camp

    I am following a Reddit guide to dual boot Windows 7 on my late-2011 MBP. I've done every step up to installing Windows 7, but there is no check box to "Install Windows 7 or later" in Boot Camp. I've tried several other resources but none mention thi

  • Why is dreamweaver's FTP so slow!!!

    Why is Dreamweaver so slow to open up the server-side view of a web site? Thought it was my slow web site or connection. After the script finally timed out claiming the server was taking too long, I tried Transmit. Guess what? It just POPPED open. Ma

  • How can I join/Full outer join two different columns instead of union all?

    Hi, I have a scenario as the following: I am performing set operations using obiee 11g where I want to take values from two different criteria. Howwver, I dont want union to take place, instead i want join to take place to see all the columns in the

  • Vendor change in PO

    Dear Experts, We have created PO for Vendor X and subsequent goods movements has taken place. As we are using QM, usage decision was also made and stock has been moved to unrestricted use. Being this PO is for material(Customer will provide material