#How can I convert a String into a JLabel?

30 messages · Page 1 of 1 (latest)

vagrant veldt
cloud moatBOT
#

This post has been reserved for your question.

Hey @vagrant veldt! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

elfin canopy
# vagrant veldt

you can't however the constructor JLabel(String) accepts a String that will be displayed as the text of the JLabel

vagrant veldt
#

Is there any other way?

vagrant veldt
#

Yes

#

Its stored like this:

elfin canopy
#

you are just printing the output of the toString() method to the file, aren't you ?

vagrant veldt
#

no I write the JLabel dirctly in it

elfin canopy
#

how exactly ?

vagrant veldt
elfin canopy
#

yeah that's what I meant. Have a look at ObjectInputStream and ObjectOutputStream if you are trying to store and load the entire state of the object. This is pretty easy to implement since JLabel implements the Serializable interface. Otherwise you may also find it beneficial to write your own save/load mechanism if you only need certain properties.

vagrant veldt
#

How exactly?

vagrant veldt
#

Why is there no file?

elfin canopy
#

because you referenced a folder

vagrant veldt
#

Hä?

#

where do you mean?

#

wait I have it

#

Now I juse Input and Outputstream and how can I store the data in the variables when I read?

vagrant veldt
#

thx

#

It says the I cant serialize static variables

vagrant veldt
elfin canopy
vagrant veldt
#

Is there no other way to save a JLabel and load it?

elfin canopy