Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Remove item from table

  1. #1
    Junior Member
    Join Date
    Jul 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Remove item from table

    Hi to everybody!

    I'm trying to make a calendar that, when you click on the date, the result are stored in a map and visualized in a table that refers to a container.

    I successfully created the map mechanism, but I have a problem on the list....

    I add the rows in this way:

    Object newItemId = container.addItem();
    Item riga = container.getItem(newItemId);
    riga.getItemProperty("Timestamp").setValue(fara);
    riga.getItemProperty("Date").setValue(asa);
    .

    How can I delete a row in the list, when all I have in input is the "Timestamp" information, in a Long value?

    Thanks for the answers

    BTY, I'm using NetBeans with Vaadin extension


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Remove item from table

    How can I delete a row in the list, when all I have in input is the "Timestamp"
    The normal way would be to:
    search the list for the item to delete
    remove the item

    Are you asking about a java class that implements the List interface?
    What kind of objects are stored in the list?
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Jul 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Remove item from table

    I managed to make it run in this way

    private void refreshContainer(IndexedContainer container, Map<Long,Date> mappa)
        {
            container.removeAllItems();
    //        Iterator it = mappa.entrySet().iterator();
            for (Date d:mappa.values())
            {
                container.addItem(d);
                container.getItem(d).getItemProperty("Date").setValue(d);
            }
        }

    But how can I sort the item in this container?
    The column is called "Date", as you can see in the code, but how I can avoid writing directly in this method the name of the fields of the table?

    Thanks

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Remove item from table

    But how can I sort the item in this container?
    What is the IndexedContainer class? What class does it extend? What interfaces does it implement?
    Can any of them be used by one of the Collections sort() methods?
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. adding data in table but the table is in another frame
    By brianskiee in forum What's Wrong With My Code?
    Replies: 3
    Last Post: March 13th, 2014, 03:31 PM
  2. display item for item selected in combobox
    By cisco.nat in forum AWT / Java Swing
    Replies: 1
    Last Post: June 20th, 2013, 07:12 AM
  3. how to display item above....help me to do this...
    By aicue in forum What's Wrong With My Code?
    Replies: 2
    Last Post: January 9th, 2013, 12:40 PM
  4. Adding add/remove button to add/remove tab
    By JMtrasfiero in forum What's Wrong With My Code?
    Replies: 6
    Last Post: March 27th, 2012, 11:24 AM
  5. drag item or insert item into new Jlabel in JPanel
    By qaromi in forum AWT / Java Swing
    Replies: 5
    Last Post: July 6th, 2010, 07:37 PM