File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Swing/JButton Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Swing/JButton" Watch "Swing/JButton" New topic



Joined: Jul 05, 2001
Posts: 5
Hello sir,
Thanks for u'r reply i got for my previous doubt in JTabbedPane.
Now i have a doubt & i need a solution.
I am using JButton.The size for the button is small but i the String to be displayed on the button is large.
So i need the text to displyed as for example:
title is
How should i write the constructor:
JButton jb1=new JButton("the title is");
i need the text to be displayed only as said above in two lines.
How should i specify in the constructor.
I am working in JBuilder.
It doesn't support the constructors like
JLabel jl=new JLabel("the
title is"); as it is supported by others(forte).
If jbuilder supports i must have applied this label to button
& my pbm must have solved.
so pl.. help me as soon as possible.
with regards,

Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040
Re-requesting your cooperation.
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please log in with a new name which meets the requirements.
ps: Please note that you were already informed about this in your other post by Frank.

Take a Minute, Donate an Hour, Change a Life
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Sonara,
Try this:
JButton jB = new JButton( "< HTML >Middle
button< / HTML >" );
I edited the HTML tags and added spaces so that they show-up properly.
- satya

[This message has been edited by Madhav Lakkapragada (edited July 06, 2001).]

Joined: Jul 05, 2001
Posts: 5
hello Sir ,
I am really happy with the replies with what i get.
It works perfectly for me.Thanks a lot.
One More problem, i have panel1.
Panel1-North has Panel2(panel2 has 5 buttons).
Panel1-center has Panel3.
when each button is pressed i have add a panel(which is different for each 5 buttons say p1,p2,p3,p4,p5) ,but all to Panel3.
one common Panel-panel3 but when button pressed different panels to be added only to panel3.
when 1st button is pressed i add p1 to panel3.
when 2nd button is pressed i give jpanel3.removeAll() & then add p2 to panel3.
But removeAll doesn't work .
pl suggest me a solution.
excepting u'r reply today itself.Pl... sir.
with regards
San Su
Ranch Hand

Joined: Jul 06, 2001
Posts: 313

> jpanel3.removeAll() & then add p2 to panel3.
add the following code after you add the panel2 to panel3
jpanel3.removeAll(); |
jpanel3.add(p2); | Your code...
// add the following..

This should solve your problem. I didnt test it. If it
doesnt work, please let me know..
I agree. Here's the link:
subject: Swing/JButton
It's not a secret anymore!