Only 44 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



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

Multiline Button  RSS feed

 
Meghna ks
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I need to wrap text in a JButton.
eg. This is javaranch.
wherein This is -> first line & javaranch -> second line
How do I do this with the button's size not being changed.
Thanks
meghna
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

You can set the font and font size to whatever you need.
ps:
Paul: I added [ code ] opening and closing tags and the spaces so the HTML is preserved.
regds.
- satya

[This message has been edited by Madhav Lakkapragada (edited June 22, 2001).]
 
Martin webster
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
One way of displaying multi-line text into a button is by using HTML within the text.. ie
jButton1.setText("< HTML >This is
Java ranch< / HTML >");
However the preferred size of a button is always dependent on the font and the insets used. Using this approach also overides any set fonts that may have been already attached to the button.
Other than that I'm unsure... I'm having a similar problem with wanting to display multiline text within a label, which I've had to solve by creating a text area, which behaves like a label... nasty
ps:
I added the spaces for the HTML tags so that they show up in your post.
- satya

[This message has been edited by Madhav Lakkapragada (edited June 21, 2001).]
 
Martin webster
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Of course displaying HTML witin an HTML page means that what I've just typed has not work.. should be
jButton1.setText("{HTML}This is {BR}Java ranch{/HTML}")
where { is <
 
Meghna ks
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Thanks for the immediate response. I guess wrt the problem of wrapping text in a label, there is a wrapping label component itself. Check it out in symantec.itools.awt.WrappingLabel. This should solve ur problem.
Meghna
 
Meghna ks
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi paul
I don't think so the method u've suggested would work. Its going to bring up the + in the button text also. Thanks for the i/p.
Meghna
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It lost all of the {HTML} formatting that I put in. The plus sign just continued the string. I just cut it out of what was in the sun tutorial.
 
Meghna ks
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Paul
Could you please mail me the URL where you found the HTML code ?!!
Thanks
Meghna
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Meghna:
You could find the Tutorials here.
Hope I am not stepping on Pauls' feet.
regds.
- satya
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!