Instead of asking a question here, supply the information!
Is it the world? and if not, then what kind of class is it?
(And do not just say 'yes'; instead, say 'yes, it is the world', or maybe 'no, it is an Actor', or whatever).
Yes, i was thinking that; it's why I asked: (i.e. TextMaker is your world class?)
If it's not then you need to do one of two things: (1) get a reference to a TextMaker instance and then access the txtString variable from that or (2) declare txtString as "static" (public static String txtString = "";) and then access it as "TextMaker.txtWorld".
The first option is generally preferable. The second one is less work, but it may cause you some problems (for one thing, if you have more than one TextMaker, they will all share the same value for txtWorld; also, if you press "reset" the value of a static variable will not be reset).
And, danpost is right: you need to supply more information. Your questions are vague and difficult to answer.
In my previous post, just above, I had to give two possible solutions, because I don't know what you're trying to do exactly nor why. If I had more information I could have spared myself some effort; or, I could have gone into more detail on the solution that is appropriate. I'm less likely to try and help if it takes unnecessary effort, and others surely feel the same way!
Questions that spring to mind are:
what is TextMaker exactly - is it a world, or an actor, or neither?
If TextMaker is an actor type, have you placed one in the world?
Can there only ever be one TextMaker or can there more than one?
What is TextMaker meant to do, or what does it represent?
What does the value of the txtString variable represent or mean?
Why exactly do you need to access the "txtString" variable from your SaveButton class?
The point is, you are asking for help, so you should provide as much information as possible so that it is easier for people to help you!
ok, here goes:
TextMaker is an actor
There is one in the world
There can be more than one
it represents the text that you type
txtString contains the text
and i am trying to save a file that contains what you type, when you press SaveButton
That makes things clearer!
In your SaveButton class, something like getWorld().getObjects(TextMaker.class) will return a list of all the TextMaker objects in the world. If there's only ever going to be one you can just get the first item in the list returned from that method and use that. "textMaker.txtString" (assuming textMaker is the variable where you have put your object obtained above) will then give you the value of txtString in that object.
Since there's only 1 TextMaker in the world you could use the approach davmac outlined above and make it static so it can be accessed from the class. However, not making it static would be the better option since if at a later date you want to add another TextMaker you won't need to refactor (change) your code so much and it should just work.
Well that's another reason why not using the static approach would be best!
But you shouldn't need another object just because there's two lines of text - as long as your TextMaker class can cope with entering a new line. It can still all be stored in the one string; the lines would be separated by new line characters (\n).
In your SaveButton class, something like getWorld().getObjects(TextMaker.class) will return a list of all the TextMaker objects in the world. If there's only ever going to be one you can just get the first item in the list returned from that method and use that.
The items in the list are the references to all the "TextMaker"s in the world. If there's just one, then the first (and only) item in the list will be the one you want.