This site requires JavaScript, please enable it in your browser!
Greenfoot back
erdelf
erdelf wrote ...

2012/7/22

JPanel in GreenfootWorld?

erdelf erdelf

2012/7/22

#
Is there a way to add a JPanel in the GreenfootWorld and not in a seperated JFrame?
SPower SPower

2012/7/23

#
I don't think so, what are you trying to accomplish?
erdelf erdelf

2012/7/23

#
I want to use a JPanel in the Greenfoot world, cause it looks better then in a seperated Window
nccb nccb

2012/7/23

#
I don't think this is feasible. Even though the world is ultimately in a JPanel, with things like the hooks to capture keyboard and mouse input in the world, I reckon trying to display a GUI in the world isn't feasible without customising big chunks of Greenfoot. You'll have to live with the separate window, I'm afraid.
erdelf erdelf

2012/7/23

#
damn, I will look after other methods of implementing JPanels
Upupzealot Upupzealot

2012/7/28

#
I looked into Greenfoot's source code. As @nccb said, the world is based on a JFrame. But, it use different classes when it run as a JAR file or in the Greenfoot program. For Jar packages, it's based on a class GreenfootScenarioViewer which extends from JApplet. When it runs in the Greenfoot program, it's based on a class called GreenfootFrame which extends from JFrame. I think it will help, if you look into Greenfoot's source
You need to login to post a reply.