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

2012/1/15

Pop-ups

Duta Duta

2012/1/15

#
I noticed in a lot of older scenarios, they sometimes have a pop-up which appears, giving you options on something (I'm probably not explaining this well, but still). What's the code for this? I had a glance through the API, and I couldn't track it down. Am I being dumb or is it just a feature that used to be around? EDIT: This is what I mean - go to http://www.greenfoot.org/scenarios/642 and click "Editor Mode"
kiarocks kiarocks

2012/1/15

#
Not a feature that i know of, i think it is high up java.
DMCGames DMCGames

2012/1/15

#
Im not sure but its something like this
JOptionPane.showInputDialog("//What you Want it to say");
Duta Duta

2012/1/15

#
Thanks DMCGames! :) What you do, it turns out, is add the following import statement at the start of your code:
import javax.swing.*;
and then you can do what you said, or a few other methods - see here for details I'd figured that as I wasn't seeing it in the greenfoot api, it must be a J-Something (only because I use NetBeans which is heavy on the swing framework), I just hadn't got round to looking through the list of JComponents and finding out what :L I'm lazy...
kiarocks kiarocks

2012/1/15

#
I use swing sometimes as well.
DonaldDuck DonaldDuck

2012/1/16

#
You're talking about the Jpanes. there is an input dialog, output dialog, menu dialog, and button dialog (I think I got all of them) They're really convenient for the programmer, but annoying for the user. Regardless, I use them all the time. They're helpful for getting input from the user.
kiarocks kiarocks

2012/1/16

#
Yea, I use them now as well. Very convient!
mjrb4 mjrb4

2012/1/16

#
What you're describing is part of the built in swing classes that are the default UI building toolkit for standard Java programs (at least until Java 8!) The popups are easy to use but as already pointed out they're annoying, look very separate from the Greenfoot scenario and in many browsers the warning triangle that pops up by them to warn you that they're part of an applet can make users a bit suspicious that something else is going on! I've used them a few times but usually changed them to something else later, they might be good as a quick hack but I wouldn't recommend using them permanently. You'd be much better using some of the widgets people have built that sit inside the Greenfoot scenario - for the most part they're just as easy to use and they look a lot better too!
You need to login to post a reply.