Results 1 to 6 of 6
  1. #1
    banhbaochay is offline Member
    Join Date
    Apr 2010
    Posts
    32
    Rep Power
    0

    Default Use JTable without using Vector

    Hi everybody,
    I usually create table through DefaultTableModel(Vector data, Vector column). But now I know Vector is obsolete, I also now DefaultTableModel use Vector in its code. So how should I create table without using Vector?
    Thanks for reading :)

  2. #2
    eRaaaa is offline Senior Member
    Join Date
    Oct 2010
    Location
    Germany
    Posts
    787
    Rep Power
    5

    Default

    Use your own table model.
    Implement your table model in a subclass of the AbstractTableModel class and use e.g. a list or an array.
    see How to Use Tables (The Java Tutorials > Creating a GUI With JFC/Swing > Using Swing Components)

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by banhbaochay View Post
    Hi everybody,
    I usually create table through DefaultTableModel(Vector data, Vector column). But now I know Vector is obsolete, I also now DefaultTableModel use Vector in its code. So how should I create table without using Vector?
    Vector is not obsolete and certainly hasn't been deprecated. Where have you read this?

    It may be a little slower than an ArrayList since it is synchronized while ArrayList isn't, but again, it hasn't been deprecated and is fully supported by Java now and in the forseeable future.

    Incidentally, if you want to use your own data structure as the nucleus of your JTable model, then subclass AbstractTableModel, but be prepared to do a bit more work to get it working.

  4. #4
    banhbaochay is offline Member
    Join Date
    Apr 2010
    Posts
    32
    Rep Power
    0

    Default

    Thanks eRaaaa and Fubarable, I use Netbeans 6.9 and it marks Vector is obsolete. Then I search on google about "Vector obsolete", I found many forum said that: "Java Vector is obsolete because it's synchronized".

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by banhbaochay View Post
    Thanks eRaaaa and Fubarable, I use Netbeans 6.9 and it marks Vector is obsolete.
    What specifically does NetBeans state in its warning? What's the exact wording?


    Then I search on google about "Vector obsolete", I found many forum said that: "Java Vector is obsolete because it's synchronized".
    Information found in fora is not guaranteed to be correct. Have you found anything regarding this on the official Oracle Java sites?

  6. #6
    banhbaochay is offline Member
    Join Date
    Apr 2010
    Posts
    32
    Rep Power
    0

    Default

    Quote Originally Posted by Fubarable View Post
    What specifically does NetBeans state in its warning? What's the exact wording?
    I have this picture to show it:


    Information found in fora is not guaranteed to be correct. Have you found anything regarding this on the official Oracle Java sites?
    No, I only read information in some forum :(

Similar Threads

  1. Vector<vector> loop thru
    By ocean in forum New To Java
    Replies: 11
    Last Post: 11-21-2009, 02:17 PM
  2. JTable, Vector, File, Problem.
    By ocean in forum New To Java
    Replies: 4
    Last Post: 11-06-2009, 07:51 AM
  3. Vector
    By MuslimCoder in forum Advanced Java
    Replies: 4
    Last Post: 08-06-2009, 03:44 PM
  4. Replies: 1
    Last Post: 04-06-2009, 06:45 AM
  5. Replies: 2
    Last Post: 05-15-2008, 10:15 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
  •