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

2015/1/14

Help Plz

DemonsWhiteSoul DemonsWhiteSoul

2015/1/14

#
So i was going to make it so when you a image, it will ask you for you name then say "hello" + Name. I dont know how i would do this. any help plz? Here is the code. import greenfoot.*; import javax.swing.*; public class Joker extends Object { public void act() { if (Greenfoot.mouseClicked(this)) { String inputValue = JOptionPane.showInputDialog("What is your name?"); JOptionPane.showMessageDialog(null,"hello " + Name); } } int Name; }
xFabi xFabi

2015/1/14

#
i think i can remember sth like
public void method(string Name)
and it would ask for the name when its executed, maybe this helps
DemonsWhiteSoul DemonsWhiteSoul

2015/1/14

#
i'll try it out, thanks
DemonsWhiteSoul DemonsWhiteSoul

2015/1/14

#
But is there a way to make what ever they type in a variable to use later on?
Super_Hippo Super_Hippo

2015/1/14

#
String inputValue = JOptionPane.showInputDialog("What is your name?");
This line saves the input in the variable 'inputValue'. Either you change this to 'name' (or in your case 'Name', but you should change both to 'name') or you change the 'Name' in next line to 'inputValue'.
DemonsWhiteSoul DemonsWhiteSoul

2015/1/15

#
Thanks^
You need to login to post a reply.