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

2015/2/4

How do i make a text input on screen on greenfoot world

coder04 coder04

2015/2/4

#
this is my text input but i would like it to show on greenfoot world
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import javax.swing.JOptionPane;
/**
 * Write a description of class Text here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Text extends Actor
{
    /**
     * Act - do whatever the Text wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {
        if (Greenfoot.mousePressed(this)) {
        String inputValue = JOptionPane.showInputDialog("Please input a sentence");
    }
    }    
}
davmac davmac

2015/2/4

#
Could you not just use the Greenfoot.ask(...) method?
You need to login to post a reply.