Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Having problems with Window and Frame

 
John Quach
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1951
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
John Quach
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's the other code in the hierarchy. Sorry I forgot to include this one

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic