Win a copy of Pragmatic AI this week in the Artificial Intelligence 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:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Swing/JButton  RSS feed

 
Greenhorn
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:
the
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,
Sonara.

 
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Sonara",
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 http://www.javaranch.com/name.jsp . 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.
Thanks
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 >" );
Regards,
Manfred.
Manfred:
I edited the HTML tags and added spaces so that they show-up properly.
regds.
- satya

[This message has been edited by Madhav Lakkapragada (edited July 06, 2001).]
 
Sonara
Greenhorn
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
Sonara.
 
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..
((JComponent)jpanel3.getParent()).revalidate();
jpanel3.revalidate();
jpanel3.repaint();

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!