Wads a class Window/window argument?

Hi all,
I had came across in a java2 book which i am reading, which covers casting objects. However, I do not quite understand one of its examples.

Quote:
For example, consider a method that takes two arguments, one of type objects and another of type window. You can pass an instance of any class for the object argument because all java classes are subclasses of object. for the window argument, you can pass in its subclasses, such as Dialog, FileDialog and Frame.

What exactly is a window and on what occations does casting of objects come into hand? Thanks.. =D
eturfclubAsked:
Who is Participating?
 
CEHJConnect With a Mentor Commented:
>>What exactly is a window

A Window (not the capital letter) is the base class for all components that represent a window on the platform on which Java is running

>>on what occations does casting of objects come into hand?

Your own quote gives a clue to this:

>>for the window argument, you can pass in its subclasses, such as Dialog, FileDialog and Frame.

so you could have a method such as the following:


void handleWindow(Window w) {
      if (w instanceof Frame) {
            Frame f = (Frame)w;
            // do something with 'f'
      }
      else if (w instanceof Dialog) {
            Dialog d = (Dialog)w;
            // do something with 'd'
      }
}

Note the casting
0
 
CEHJCommented:
>>not the capital letter

should be

note the capital letter
0
 
eturfclubAuthor Commented:
meaning that the Window is only used for application which has an interface like MS word and etc instead of the DOS(console based) ?
0
 
CEHJCommented:
8-)

Yes, a normal windowed gui, not a console
0
 
eturfclubAuthor Commented:
thanks.. =)
0
All Courses

From novice to tech pro — start learning today.