Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to create display lines on label of JButton

Status
Not open for further replies.

srikandula

Programmer
Dec 28, 2000
31
US
Can any one help me in this.

I have created a JButton and wanted to the text to be displayed as follows on its label.

--------------------
| Close |
| Exit |
--------------------

That is i want to indicate both close and exit labels for the button but on different lines.can any one help me in doing this.The help will be very much appreciated.

srinu

 
Maybe try a newline in the string like:

...= new JButton("Close \n Exit");

not sure - could work?
b2 - benbiddington@surf4nix.com
 
Hi,

From what I know, there is no way that you can have 2 lines in a button. The only way I can think of is to create your own button class but it would take some time.

Regards,
Leon If you need additional help, you can email to me at zaoliang@hotmail.com I don't guaranty that I will be able to solve your problems but I will try my best :)
 
I think if you force the button to be narrow but tall, the text will wrap.

Rose/Miros
 
Hi Miros,

Unfortunately it won't work. If you really try it out, the output would be something like :-

---------
|Hell...|
---------

So I guess the only way is still to create your own button class :)

Regards,
Leon If you need additional help, you can email to me at zaoliang@hotmail.com I don't guaranty that I will be able to solve your problems but I will try my best :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top