Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Multiline Button

 
Meghna ks
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I wanted to know how multiple lines can be wrapped inside a button with the button's size being unchanged. I did go thro' the HTML way of doing this. But is there any other way apart from using HTML tags to do this ?!!
Thanks
Meghna
 
Swamy Vatti
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One way to get around this is to add labels to the button. Looks something like this.
public class MultiLineButton extends javax.swing.JButton {
public MultiLineButton(String[] array) {
super();
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
for (int i = 0; i < array.size, i++) {
this.add(new JLabel(array[i]));}
}
}
or if u can parse the string with some delimiter, the parameter can be a string...I have tried this and works fine. but let me know how it works in urs...
 
Who among you feels worthy enough to be my best friend? Test 1 is to read this tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!