Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / June 2006

Tip: Looking for answers? Try searching our database.

Can't understand syntax error with Java 6.0

Thread view: 
Wes Harrison - 28 Jun 2006 23:14 GMT
I am getting a syntax error in my Java code that I cannot understand and
hope you can help me.  It's with Java 6.0 and TableRowSorter.  The line of
code is:

table.setRowSorter(new TableRowSorter(tableModel));

where table is a JTable and tableModel is an implementation of an
AbstractTableModel.  The errors I get are:

MyTable.java:204: warning: [unchecked] unchecked call to TableRowSorter(M)
as a member of the raw type javax.swing.table.TableRowSorter
   table.setRowSorter(new TableRowSorter(tableModel));
                                                          ^
MyTable.java:204: warning: [unchecked] unchecked conversion
found   : javax.swing.table.TableRowSorter
required: javax.swing.RowSorter<? extends javax.swing.table.TableModel>
   table.setRowSorter(new TableRowSorter(tableModel));

What do they mean exactly and how do I fix the problem?

Thanks,

Wes
Danno - 29 Jun 2006 06:00 GMT
> I am getting a syntax error in my Java code that I cannot understand and
> hope you can help me.  It's with Java 6.0 and TableRowSorter.  The line of
[quoted text clipped - 19 lines]
>
> Wes

Show us what tableModel looks like ;)
Bjorn Abelli - 29 Jun 2006 11:42 GMT
"Wes Harrison" wrote...

> I am getting a syntax error in my Java code that I cannot
> understand and hope you can help me.

It's not a syntax error, not even an error. It's a compiler warning.

Read the lines again, and you'll see that it's a warning that something's
"unchecked".

warning: [unchecked]

> What do they mean exactly and how do I fix the problem?

It means that you can get your application more typesafe by using generics,
i.e. to provide in the source code what type of TableModel your
TableRowSorter is supposed to handle.

When using that option, it means that it will do further checks in the
compilation that you won't use any other TableModel than your specific
implementation of it.

You don't *have* to do anything, as it's not a "problem". If it compiled
with only those warnings, the compilation still got through.

/// Bjorn A


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.