Is there such thing as a getClass() method like the getWorld() method?
public String txtString = "";
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) import java.io.*; /** * Write a description of class SaveButton here. * * @author (your name) * @version (a version number or a date) */ public class SaveButton extends Actor { /** * Act - do whatever the SaveButton wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { try{ // Create file FileWriter fstream = new FileWriter("out.txt"); BufferedWriter out = new BufferedWriter(fstream); out.write(getWorld().getStringFromObject(TxtString));<here!! //Close the output stream out.close(); }catch (Exception e){//Catch exception if any System.err.println("Error: " + e.getMessage()); } } }
out.write(((TextMaker)getWorld()).txtString);