3 Replies Latest reply on May 31, 2012 6:31 PM by morgalr

    JTextPane font size problem

      I have a JTextPane. i have set the content type to 'html'. but the problem is i am not able to reduce the size of the string that i obtain from my beans. The following is my code
      JTextPane ackTP=new JTextPane();          
      private String buildTestSlip(TestRegisterDto registerDto){
                String imgPath=Resources.class.getResource("lucidfull.jpg").toString();
                StringBuffer sb=new StringBuffer();
                String testSlip="<table>" +
                                         "<tr><td width='700' align='right'><img src='"+imgPath+"'/></td></tr>" +
                                    "</table><br>" +
                          "<table border='0'><tr><td width=350><b><font size='2'>Registration Number : </b>"+registerDto.getRegNumber()+"</font></td><td width='350' align='right'><b>Registration Date : </b>"+registerDto.getDate()+"</td></tr></table><br>";
         return sb.toString();
      Inside the table i have declared font tag for "registration number" so the size got reduced for that but i have taken the value that is registration number
      from the registerDto bean. this value is being displayed in a fixed size. this is not getting reduced.
      kindly help me in this. how to reduce this size?

      Edited by: sabre150 on May 30, 2012 9:06 AM

      Moderator action : removed surplus {code } tags from simple text.
        • 1. Re: JTextPane font size problem
          I am unsure of what you are fully saying there:

          If you have a font tag in your data, then you have to strip it out: the inner most font will be the one displayed.

          If your data is trying to be displayed in a scaled font, but that size is not available in the font, then you need to change the font to a font that will scale in size.
          • 2. Re: JTextPane font size problem
            Hi the following is the strip from my code. I am talking about this.
            "<table border='0'><tr><td width=350><b><font size="2">Registration Number : </b>"+registerDto.getRegNumber()+"</font></td>{code}
            in the above inside the <td> tag i have specified the font size. This is being applied only to the string "Registration Number : " which is inside the <td> tag but the font size is not being applied to the value that i am getting from the dto  ("registerDto.getRegNumber()"). this is also between the font tag but the size is not being applies. It is displaying in a fixed size.
            Thanks in advance.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
            • 3. Re: JTextPane font size problem
              That actually gives me an error: notice the highlighting on the string portion code... it shows to me in red. Also please notice the 2 is in a nice black color, indicating that it is not part of the string. You have a String that is typed up against an integer and then another string on the other side. It is not a valid expression, you need to escape the quotes around the 2 so you have a valid expression or change them to single quotes.