• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Multiline Button

 
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).]
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Paul
Could you please mail me the URL where you found the HTML code ?!!
Thanks
Meghna
 
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic