Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Hide part of text on JLabel  RSS feed

 
robin singal
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I have a frame using gridlayout with 240 labels packed to fullscreen. On each label i have several fields seprated with spaces which shall constantly change. How can i make a part of the text on Jlabel invisible to the user as i want to use that field for further manipulations and i can't use another frame because of memory and complexity constraints.

best regards
Robin
 
Campbell Ritchie
Sheriff
Posts: 53769
127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are probably all sort of ways to do it. You know JLabels support HTML tags, so you might be able to make the colour of the text the same as the background. But that means it would be available for highlighting and copying with ctrl-C.

Anybody else got any ideas?
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think this would be easier.
1) Extend JLabel
2) Provide a model in the constructor
3) You can generate the required text from the model and call setText() on the label.
4) You always keep manipulating the model data which in turn call a setText with the updated text if any.
 
robin singal
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I didn't got the below pt.
2) Provide a model in the constructor

what is the model part.
Moreover i would like to add that i am using a single thread model and then the program is put into infinite while loop to display all the fields randomly on any of the 240 labels.
I would also have done : as the field i want to hide from the user would be the last field so i could give many spaces in settext() and then the field that would hide the field but problem was that it would still show "..."
nways this was just a few sec. thought.
Well about campbell sugg; don't know about using html in Jlabel but i'll try it out and know what it comes out to be.

Thanks
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by robin singal:
Hi

I didn't got the below pt.

what is the model part.


 
robin singal
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the answer. ya that's easy. I'll try to superimpose the concept on my logic.
Thnx
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!