With the game that i'm currently working on, once you discover something, you have the ability to name it. I have my custom typeable text boxes working, but I don't know how to incorporate that into the Objects that I'm creating at different times as their names. How can this be accomplished? I'm really looking for a concept here on how to do this. Any help is appreciated.

It's exactly clear what the problem is. Are you having trouble getting the value in your text box into an object property? Are you trying to figure out how to store the name so that it can be used later when an instance of that object comes up?

Not quite, I'd have a new object that I want to name, and on Initialization, the consructor requires a String for a name, how do i go about taking that info from the prompt and sticking it as one of the parameters?

The problem with this is that I create the object before i get the name, so it can be shown to the player for them to name.But, if I remove the name from the constructor, and create the object. Then set the name, what would be the best way for it to remember the object at hand?

Create the object with a blank name, set it again when they enter a name in the GUI. This is GUI 101 here, any swing tutorial that covers a textbox will cover that. Since it sounds like you've got your own widgets going, the only one who knows how those work is you.

Create the object with a blank name, set it again when they enter a name in the GUI. This is GUI 101 here, any swing tutorial that covers a textbox will cover that. Since it sounds like you've got your own widgets going, the only one who knows how those work is you.

Yeah, I haven't taken any classes on java, nor have I practiced a lot int Swing. But, yeah these are custom widgets

Yeah, like sproingie said. Create the object with a blank name-string (remove it from the constructor).Then when the user hits Enter (that closes your box, right?), then before you destroy the box, do:

1

myNewObject.setName(myBox.getFinalString())

Obviously this is pseudo-code, but you should get the picture.

If you need the constructor to be able to set the name with a parameter for creating other objects, just overload the constructor, like this:

Reading a few swing tutorials to get a grasp on how it handles this kind of thing would probably be helpful if you're trying to write your own gui system. Swing may not be perfect, but it gets a lot of the basics right.

So what i've gathered from this and a tutorial or two, is that I have to 1:create a listener from the new Object that I want to name2:create a textbox for that name3:fire an event when the enter key is pressed4:have the listener deal with the event5:the listener would store the text to the object's name? if that's the basic concept, then i have that much(apart from some errors that i don't understand). Or I'm completely wrong....

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org