• Post Reply Bookmark Topic Watch Topic
  • New Topic

what is "caller" instance  RSS feed

 
Puspender Tanwar
Ranch Hand
Posts: 499
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello ranchers, it's been so long since I asked something. So, after so many months, i am back with a weird doubt (I guess).
So, here is my code :


I am working on ODI(Oracle Data Integrator ), since I am very new to this, I thought to copy some classes of ODI and run them on eclipse. When I looked through all the errors, I came up with a "caller" instance variable which is not defined in the class. Since it is called upon this , It should be a variable of the current  class (ListRenderer  here) . But when I googled this doubt, I came up with no answer.
So, at last every stupid goes to his friend only, so I am here 
could someone please explain me what's this caller instance variable is ?
 
Dave Tolls
Ranch Foreman
Posts: 3061
37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where is the error?
Is this a compilation issue, or a runtime exception?

In either case, can you post the relevant error text?
 
Puspender Tanwar
Ranch Hand
Posts: 499
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think this version of coderanch website does not have edit option. I tried to update my question but did't found the option.
Yes, the compilation error is at at //line1 (as i marked) , saying "caller cannot be resolved or is not a field".
 
Campbell Ritchie
Marshal
Posts: 56546
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If that code is actually supposed to compile, there is a caller field which has gone missing. Please check with the original to be sure you have not missed a line out, and use copy‑and‑paste. The error is not line 1 but line 20.
 
Campbell Ritchie
Marshal
Posts: 56546
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you using java.awt.Component? Why does that code have a return type of Component when it returns a label? When was it written? Please always tell us where such code comes from.
 
Dave Tolls
Ranch Foreman
Posts: 3061
37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The method from ListCellRenderer (and by extension DefaultListCellRenderer) returns an awt.Component.
That's how the renderers work.

Of course, the overridden method could return JLabel instead...
 
Campbell Ritchie
Marshal
Posts: 56546
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you.
 
Puspender Tanwar
Ranch Hand
Posts: 499
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:If that code is actually supposed to compile, there is a caller field which has gone missing. Please check with the original to be sure you have not missed a line out, and use copy‑and‑paste. The error is not line 1 but line 20.


I have copy pasted the code. Don't know how this code is working in ODI. And error is at line 21

By the way, why new version of coderanch doesnot have edit option ?
 
Campbell Ritchie
Marshal
Posts: 56546
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It says this.caller in the line with the compiler error. That means there has to be a member of the current object called caller. I can't see that member anywhere in the code you wrote. Please supply the original source, as I asked earlier.
There is another thing about the code which I can't understand: how are you getting a URL when you are using getResource on a .gif file?

Editing is discussed here.
 
Paul Clapham
Sheriff
Posts: 22832
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:There is another thing about the code which I can't understand: how are you getting a URL when you are using getResource on a .gif file?


The getResource() method is defined to return a URL.

In the example given it's quite possible that the URL is a file:// URL or maybe a jar:// URL.
 
Puspender Tanwar
Ranch Hand
Posts: 499
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
problem solved
I downloaded and imported a jar file which contains NameSpace, BshClassManager and many more classes to support them.

instead of this code,  I created a manager instance of BshClassManager class and called its method getResource(String s) on manager.
getResouce() is used to load files.


so I reduced the code, instead of creating firstly the instance of NameSpace and then creating instance of BshClassManager and then calling BshClassManager class method, I directly created BshClassManager instance and called the getResource(String s) to get the resource.
 
Campbell Ritchie
Marshal
Posts: 56546
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Puspender Tanwar wrote:. . . . . ..
That code looks a lot better without the multiple dots. But I still can't see how you are going to get a URL out of a .gif file. I have just remembered; the getResource method creates a URL allowing you to find the .gif file. Have I finally got that bit right?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!