aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Error in Vector<> .while using netbeans Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Error in Vector&lt;&gt; .while using netbeans" Watch "Error in Vector&lt;&gt; .while using netbeans" New topic
Author

Error in Vector&lt;&gt; .while using netbeans

Yuta Lolap
Ranch Hand

Joined: Jun 03, 2012
Posts: 83

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

Joined: Oct 16, 2003
Posts: 1085
    
  10

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).


Ranga.
SCJP 1.4, OCMJEA/SCEA 5.0.
Nam Ha Minh
Ranch Hand

Joined: Oct 31, 2011
Posts: 498

The "<>" in "Vector<>" is only compiled since Java 7, so your JDK/JRE maybe outdated.


PM Me If You Want to get Urgent Help on Java Programming
Yuta Lolap
Ranch Hand

Joined: Jun 03, 2012
Posts: 83

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

Joined: Jun 03, 2012
Posts: 83

I get the following output. I can get the data in my vectors but i cannot see it in the GUI!


Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4659
    
    5

Why are you using Vector instead of ArrayList? ArrayList is what replaced Vector over ten years ago.

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39393
    
  28
But some of these Swing components still insist one pass a Vector to their constructors.
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4659
    
    5

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

Joined: Oct 16, 2003
Posts: 1085
    
  10

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

Joined: Oct 13, 2005
Posts: 39393
    
  28
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

Joined: May 03, 2008
Posts: 4638
    
    5

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

That would be JavaFX 2


luck, db
There are no new questions, but there may be new answers.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error in Vector&lt;&gt; .while using netbeans