• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error in Vector<> .while using netbeans

 
Yuta Lolap
Ranch Hand
Posts: 86
Eclipse IDE Java jQuery
  • Mark post as helpful
  • send pies
  • 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?

 
Ranganathan Kaliyur Mannar
Bartender
Posts: 1101
10
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • 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).
 
Nam Ha Minh
Ranch Hand
Posts: 504
Eclipse IDE Firefox Browser Windows
  • Mark post as helpful
  • send pies
  • 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
Eclipse IDE Java jQuery
  • Mark post as helpful
  • send pies
  • 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
Eclipse IDE Java jQuery
  • Mark post as helpful
  • send pies
  • 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!


 
Pat Farrell
Rancher
Posts: 4678
7
Linux Mac OS X VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you using Vector instead of ArrayList? ArrayList is what replaced Vector over ten years ago.

 
Campbell Ritchie
Sheriff
Pie
Posts: 50168
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But some of these Swing components still insist one pass a Vector to their constructors.
 
Pat Farrell
Rancher
Posts: 4678
7
Linux Mac OS X VI Editor
  • Mark post as helpful
  • send pies
  • 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: 1101
10
Java Netbeans IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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
Sheriff
Pie
Posts: 50168
79
  • Mark post as helpful
  • send pies
  • 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.
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic