aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Having problems with Window and Frame Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Having problems with Window and Frame" Watch "Having problems with Window and Frame" New topic
Author

Having problems with Window and Frame

John Quach
Ranch Hand

Joined: Sep 28, 2011
Posts: 50
I'm reading a book called Developing Games in Java by David Bracken.

I have finished a semesters worth of java in college and have since then been exploring ways to make games out of java.

My problem is that I can't seem to get these two classes ( Which are straight out of the book ) to work with each other. I'm running eclipse and I am getting red squiggly lines on line 47 and line 73 from the MenuTest Class.

JFrame frame = super.screen.getFullScreenWindow();

The error message says "Cannot convert from Window to JFrame". Can someone help me please? The following are the two classes I'm talking about.




Jelle Klap
Bartender

Joined: Mar 10, 2008
Posts: 1761
    
    7

Hmmm, well InputManagerTest class seems to inherit its screen member variable, and I've no idea what its type is or what its getFullScreenWindow() actually returns at runtime, but it seems to return a reference to an instance of java.awt.Window. You can't just assign that reference to a javax.swing.JFrame variable, but because they are in the same inheriance tree you could try explicitly casting to a JFrame. Although that could very well result in a ClassCastException at runtime, because the reference might not actually point to a JFrame instance at all.


Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
John Quach
Ranch Hand

Joined: Sep 28, 2011
Posts: 50
Here's the other code in the hierarchy. Sorry I forgot to include this one

 
Consider Paul's rocket mass heater.
 
subject: Having problems with Window and Frame