Results 1 to 3 of 3
  1. #1
    Rageagainst20 is offline Member
    Join Date
    Dec 2007
    Rep Power

    Default Listbox Add/Delete

    I have read countless tutorials on how to do this yet I am still stuck

    I think the problem is that most tutorials are manually drawing their Lists

    I have a JFrame with a JList dragged onto it (I am using Netbeans)

    I want to press one button to add to the list box and one to delete (delete the item selected)

    I have tried using getSelectedIndex etc

    But it doesn't delete anything and a lot of errors occur in the Output console

    I have seen a lot of mention of something like DefaultListModel or something named similar

    Where can I be going wrong, there isn't even a remove option like most tutorials say. Let me repeat for clarities sake I am a newb I only started using this program 2 weeks ago but I know that I don't want to draw a New list box in another form


  2. #2
    java_fun2007 is offline Member
    Join Date
    Nov 2007
    Rep Power


    I have the same problem too, I read that I should use Array of items then use add(array) to add to the list. I tried it but it's not working also I read about DefaultListModel and tried it and stills the item is not added to the list.
    what is the difference between the two ways of adding to the JList?

  3. #3
    sukatoa's Avatar
    sukatoa is offline Senior Member
    Join Date
    Jan 2008
    Cebu City, Philippines
    Rep Power


    first, obviously you set the values into the list... and it exactly shows the consequences depends on how had you arrange them accordingly.... right?

    for example, i have

    deftones, El Nino, Underground, hardcore

    Well, you can put it in the list....

    What if i like to delete El Nino?

    Then, delete El Nino,

    Replace all the values from the list and put this again,

    deftones, Underground, hardcore

    correct me if im wrong,

Similar Threads

  1. delete string in JtextArea
    By cloudet in forum AWT / Swing
    Replies: 3
    Last Post: 05-05-2008, 10:06 AM
  2. Store retrieve and delete
    By on7june in forum New To Java
    Replies: 1
    Last Post: 03-08-2008, 05:57 PM
  3. problem when I try to delete a file
    By tommy in forum Advanced Java
    Replies: 2
    Last Post: 07-31-2007, 02:44 PM
  4. Doubt in edit and delete methods
    By ai_2007 in forum Advanced Java
    Replies: 3
    Last Post: 07-01-2007, 11:40 AM
  5. How to delete a file
    By Alpha in forum New To Java
    Replies: 1
    Last Post: 05-26-2007, 08:11 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts