• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JTextPane/Styleconstants

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Friends,
Below I have given the code all attributes like bold,background color is working fine but not the linespacing attribute.
Could u pl.. help me out in this regard.
public class Sample extends JFrame {
private JTextPane jTextPane1 = new JTextPane();
JTextPane jt2=new JTextPane();
StyledDocument doc=null;
String as="<html><head></head><body>This is first line.This is second line.This is thrid line.This is first line.This is second line.This is thrid line.</body></html>";
public Sample() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
private void jbInit() throws Exception {
this.getContentPane().setLayout(null);
jt2.setBounds(150,0,150,350);
jt2.setContentType("text/html");
jt2.setOpaque(false);
Color white=new Color(255,255,255);
MutableAttributeSet set=new SimpleAttributeSet();
jt2.setText(as);
jt2.setBorder(javax.swing.border.LineBorder.createBlackLineBorder());
JLabel jlab=new JLabel();
doc=jt2.getStyledDocument();
int len=jt2.getDocument().getLength();
javax.swing.text.StyleConstants.setLineSpacing(set,25.25f);
javax.swing.text.StyleConstants.setBackground(set,white);
javax.swing.text.StyleConstants.setSpaceAbove(set,95.5f);
javax.swing.text.StyleConstants.setBold(set,true);
doc.setCharacterAttributes(0,len,set,false);
this.getContentPane().add(jt2);
}
public static void main(String args[])
{
Sample fr2=new Sample();
fr2.setSize(500,500);
fr2.setVisible(true);
}
}
Thanks & regards,
Nivi.
 
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I hate you do this.but thought it would be helpful please go through this material if you can http://www.manning.com/Robinson/chapter20.pdf.

(NEP - Fixed URL by removing period at end. )
[ November 25, 2002: Message edited by: Nathan Pruett ]
 
nivedita rajiv
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Kumar,
Thanks for u'r link.But the link u specified is not opening.So culd u pl.. send me agin.
Thanks & Regards,
Nivi.
 
Bhagya Tangutur
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
please try clicking it on now..
Thanks
 
reply
    Bookmark Topic Watch Topic
  • New Topic