This week's book giveaways are in the AI and JavaScript forums.
We're giving away four copies each of GANs in Action and WebAssembly in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of GANs in ActionE this week in the AI forum
or WebAssembly in Action in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

Multiline Button

 
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
 
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).]
 
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
 
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
 
My favorite is a chocolate cupcake with white frosting and tiny ad sprinkles.
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!