This week's book giveaway is in the Web Services forum.
We're giving away four copies of Microservices in Action and have Morgan Bruce & Paulo A. Pereira on-line!
See this thread for details.
Win a copy of Microservices in Action this week in the Web Services 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 ...
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Swing/JButton  RSS feed

Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,

Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).]
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Ranch Hand
Posts: 313
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

> 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..
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!