File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes GWT and the fly likes Google Web Toolkit : Tree.addTreeListener  is deprecated what should I use instead. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Frameworks » GWT
Bookmark "Google Web Toolkit : Tree.addTreeListener  is deprecated what should I use instead." Watch "Google Web Toolkit : Tree.addTreeListener  is deprecated what should I use instead." New topic
Author

Google Web Toolkit : Tree.addTreeListener is deprecated what should I use instead.

Laurence Turpin
Greenhorn

Joined: May 21, 2012
Posts: 19
Hello,

I'm learning about the Google web toolkit from the book "Beginning Google Web Toolkit"
I have got to the part where it starts using a Tree widget.
It uses Tree.addTreeListener() which apparently is now deprecated.
I can't work out what to use instead.

There is a class called Category and I'm creating a tree of Category.

The method below is where the problem is:

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19725
    
  20

The Javadoc says all you need to know.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Laurence Turpin
Greenhorn

Joined: May 21, 2012
Posts: 19
Thank you Rob Spoor for replying to my problem.
Unfortunately I'm not clever enough or experienced enough to work out how to rewrite the method from the Javadoc
The full method is shown below can you show me how to rewrite it please:

Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10491
    
    9

Did you check out the link Rob provided? It suggests the alternative to the tree listener.
All you need to do is replace your addXXXListener method by the method provided in the javadoc. In case you run into problems, post your modified code here and we will help you figure out what's wrong with it.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Laurence Turpin
Greenhorn

Joined: May 21, 2012
Posts: 19
Thank you for your reply Maneesh Godbole.
I'm still having problems below is my latest attempt at resolving the problem.
I get an error on one line and a warning on the line next to it.
I have marked the error line and the warning line as a comment in the code shown below.
Below my latest coding attempt I have reproduced the error message and warning message from eclipse




--------------------------------------------------------------------------------------------------------------------

Inside Eclipse I get the following error message for the line I have marked as the error line:

Multiple markers at this line
- The type new SelectionHandler<TreeItem>(){} must implement the inherited abstract
method SelectionHandler<TreeItem>.onSelection(SelectionEvent<TreeItem>)
- The type new TreeListener(){} must implement the inherited abstract method
TreeListener.onTreeItemStateChanged(TreeItem)
-------------------------------------------------------------------------------------------------------------------------------------------------

Inside Eclipse I get the following warning message for the line I have marked as the warning line:

The method onTreeItemSelected(TreeItem) from the type new SelectionHandler<TreeItem>(){} is never used locally

----------------------------------------------------------------------------------------------------------------------------------------------------
I have also tried replacing the error line with the following which also does not work:

categoryTree.addSelectionHandler(new SelectionHandler() {
Laurence Turpin
Greenhorn

Joined: May 21, 2012
Posts: 19
I finally managed to resolve my problem.
Thank you everyone for your help.
Below is the solution:


 
 
subject: Google Web Toolkit : Tree.addTreeListener is deprecated what should I use instead.