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

2017/2/24

Updating an Image with UserInput

SpicyEmpanadas SpicyEmpanadas

2017/2/24

#
I want to update a image with User input. I have the blank image (a box) as well as a method of acquiring user input. But I can't get the program to display the input from the user.
private String text = "";
    public void updateImage()
    {
        GreenfootImage image = new GreenfootImage(boxImage);    
        GreenfootImage textImage = new GreenfootImage(text, 20, Color.BLACK,
            transparent);
        image.drawImage(textImage, (image.getWidth()-textImage.getWidth())/2,
            (image.getHeight() - textImage.getHeight())/2);
        setImage(image);
    }
    
    public void UserInput()
    {
        boolean boxClick = Greenfoot.mouseClicked(this);
        if(boxClick == true && this.isFull == false)
        {
            String key = Greenfoot.getKey();
            String inputstring = JOptionPane.showInputDialog("Data:");
        }
        
Super_Hippo Super_Hippo

2017/2/24

#
'String inputstring' (line 18) is not used for anything. Maybe it has to be 'text=...'?
You need to login to post a reply.