• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

a simple question?

 
danesh far
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am a java beginner.I am trying to write a program to show some images on the screen and found one but could not undrestand this line :

Toolkit T=this.getToolkit();

what is the role of T object?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"T" is not an object, its a reference. It refers to the Toolkit object, which is an object that provides the link between AWT components and native implementations of those components.
 
Marilyn de Queiroz
Sheriff
Posts: 9061
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should call methods on 'T', the reference to the Toolkit object, to do what you need to do.
 
Marilyn de Queiroz
Sheriff
Posts: 9061
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Karim,

Welcome to JavaRanch! Please adjust your display name to meet the JavaRanch Naming Policy.
You can change it here.

Thanks!
 
danesh far
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your answer but it is still unclear to me why we need a link between AWT components and native implementations of those components.
 
Marilyn de Queiroz
Sheriff
Posts: 9061
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need a reference to the Toolkit because Java is platform independent and the Toolkit "translates" between your code and the native code of the system you are running on.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic