• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Error in Vector<> .while using netbeans

 
Ranch Hand
Posts: 86
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey,
I am getting the following error in netbeans. When i trying to use Vector. Please can you tell me exactly why am i getting this?


This inspection reports any uses of java.util.Vector or java.util.Hashtable. While still supported, these classes were made obsolete by the JDK1.2 collection classes, and should probably not be used in new development. Refactoring: No associated refactoring.


Below is the code where i am getting the error. I have imported Vector class but it is still giving me errors.


Also, To retrieve data from the database into the Jtable is it ok to use Vectors?

 
Bartender
Posts: 1104
10
Netbeans IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you run the code? when are you getting this error?
If you are able to run the code, I think you shouldn't bother with this issue.

JTable has the constructor to take a Vector. So, it will be "ok" to use it, though better way would be to use an Object[][] (even better would be use a TableModel).
 
Ranch Hand
Posts: 530
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The "<>" in "Vector<>" is only compiled since Java 7, so your JDK/JRE maybe outdated.
 
Yuta Lolap
Ranch Hand
Posts: 86
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is a warning. But i cant see any data on my Jframe Form. I cant see the table/tablepanel/jscrollpane. Basically i cant see anything.
 
Yuta Lolap
Ranch Hand
Posts: 86
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I get the following output. I can get the data in my vectors but i cannot see it in the GUI!


 
Rancher
Posts: 4803
7
Mac OS X VI Editor Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why are you using Vector instead of ArrayList? ArrayList is what replaced Vector over ten years ago.

 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But some of these Swing components still insist one pass a Vector to their constructors.
 
Pat Farrell
Rancher
Posts: 4803
7
Mac OS X VI Editor Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:But some of these Swing components still insist one pass a Vector to their constructors.



Good reason to deprecate the use of Swing :-)

I assume that nothing has come along to replace Swing with current constructs and idioms. Sigh.

The OP's problem is not just Vector usage, but Vectors with generics. I really wish that some version of Java would fix Generics so normal people can understand them. It would have to break backward compatibility, and require changes to legacy libraries, but I've spent far too many hours beating my head against generics.
 
Ranganathan Kaliyur Mannar
Bartender
Posts: 1104
10
Netbeans IDE Java Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This piece of code is fishy:

I think you have done this because the JTable is already initialized and now you want to load data. But, this is not the right way to do it. One more reason to use a TableModel.
In fact, JTable uses DefaultTableModel by 'default', so you can call table.getModel() and cast it and use the addColumn() and addRow() methods on that. In that case, you don't have to deal with this adding and removing stuff.

And when you add/remove component, you need to call revalidate() followed by repaint() - search in the Swing forum for more info on this.
 
Campbell Ritchie
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Pat Farrell wrote:

Campbell Ritchie wrote:But some of these Swing components still insist one pass a Vector to their constructors.



Good reason to deprecate the use of Swing . . . I really wish that some version of Java would . . .

I presume you have seen this thread about removing legacy code.
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Pat Farrell wrote:I assume that nothing has come along to replace Swing with current constructs and idioms. Sigh.


That would be JavaFX 2
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic