Skip to main content

Implementation of Toolkit

No replies
hoangx281283
Offline
Joined: 2008-03-25

Hi,

I'm building an automatic test application which requires references to graphics components in undertest GUI. Hence, I reimplemented my own Toolkit whose method
public FramePeer createFrame(Frame target) to be overriden in the following way:

public FramePeer createFrame(Frame target){

FramePeer fp=getUnderlyingToolkit().createFrame(target);

//invoke my own handler methods
System.out.println("Check type: "+ target.getClass());

if( target instanceof MySubclassOfJFrame){
MySubclassOfJFrame mainWindow=(MySubclassOfJFrame)target;
...................
}

return fp;
}

..........................

The output said that 'target' is of type MySubclassOfJFrame, but i could not cast it to an object of the class MySubclassOfJFrame. Someone could explain it to me?
Anyone has built an automatic test app?