Exceptions for JLabel with HTML format text.

Hi,
When the follow code been runing, and press the "Submit" button,
the follow exceptions are thrown.
How could I got a right result?
I could not find a way to work out it, and need a export help me.
Thanks and Best Regards.
Xue
JFrame f=new JFrame();
          JPanel p=new JPanel(new BorderLayout());
     JLabel label=new JLabel();
     label.setForeground(Color.blue);
     StringBuffer sb=new StringBuffer();
     sb.append("<html>");
     sb.append("<head>");
     sb.append("</head>");
     sb.append("<body>");
     sb.append("<p>A<font color=\"#FF0000\">BCD</font>E<font color=\"#FF0000\">F</font>G</p>");
     sb.append("<form method=\"POST\" action=\"http://openelec.vicp.net:8080/\">");     
     sb.append("<p>Text:<input type=\"text\" name=\"T1\" size=\"20\"><input type=\"submit\" value=\"Submit\" name=\"B1\"><input type=\"reset\" value=\"Cancel\" name=\"B2\"></p>");
     sb.append("</form>");
     sb.append("<table border=\"1\" width=\"100%\" id=\"table1\">");
     sb.append("<tr>");
     sb.append("<td align=\"center\">Name</td>");
     sb.append("<td align=\"center\">Desc</td>");
     sb.append("</tr>");
     sb.append("<tr>");
     sb.append("<td align=\"center\"><font color=\"red\"><i>Xue Chen</i></font></td>");
     sb.append("<td align=\"left\">I am a Chinese. </td>");
     sb.append("</tr>");
     sb.append("</table>");
     sb.append("</body>");
     sb.append("</html>");
     label.setSize(600,400);     
     label.setText(sb.toString());
     p.add(label,BorderLayout.CENTER);
     f.getContentPane().add(p,BorderLayout.CENTER);
     f.setSize(new Dimension(600,300));
     f.setVisible(true);     
Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: javax.swing.JLabel cannot be cast to javax.swing.JEditorPane
     at javax.swing.text.html.FormView.submitData(FormView.java:409)
     at javax.swing.text.html.FormView.actionPerformed(FormView.java:356)
     at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
     at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
     at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
     at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
     at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
     at java.awt.Component.processMouseEvent(Component.java:6038)
     at javax.swing.JComponent.processMouseEvent(JComponent.java:3260)
     at java.awt.Component.processEvent(Component.java:5803)
     at java.awt.Container.processEvent(Container.java:2058)
     at java.awt.Component.dispatchEventImpl(Component.java:4410)
     at java.awt.Container.dispatchEventImpl(Container.java:2116)
     at java.awt.Component.dispatchEvent(Component.java:4240)
     at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
     at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986)
     at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
     at java.awt.Container.dispatchEventImpl(Container.java:2102)
     at java.awt.Window.dispatchEventImpl(Window.java:2429)
     at java.awt.Component.dispatchEvent(Component.java:4240)
     at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
     at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
     at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
     at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
     at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
     at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
     at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)

Hello,
Thanks for you answer.
There is a hard problem for this topic.
how can I get the text value from text field in the html?
I can got the Document object of the html in implement interface HyperlinkListener.
Example, I input some chars in the text field<input type="text" name="T1" id="textField">.
but I can not get the text that I input in the frame.
Thanks and Best Regards
here are the codes:
* Called when a hypertext link is updated.
* @param e the event responsible for the update
public void hyperlinkUpdate(HyperlinkEvent e){
     Object src=e.getSource();
     //System.out.println(src);
     HTMLDocument doc=(HTMLDocument)e.getSourceElement().getDocument();//.getDefaultRootElement().getElementCount();
     Element el=doc.getElement("textField");//doc.getDefaultRootElement();
     System.out.println(el.toString());
     if(el!=null){                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Similar Messages

  • Display issue with HTML formatted text in report builder

    I am using the FCKeditor in my application to allow endusers
    the ability to create formated text on reports. We curently are
    experiencing 2 issues: 1. If you copy and paste from MS Word
    2003/2007 it will not display the text correclty in the report; 2.
    If you use the FCKeditor toolbar to insert bullets or a numeric
    list it will not align the text correctly on the report. We are
    using Coldfusion 8 with Hotfix 1 and Coldfusion Report Builder's
    lastest build release.
    Has one experiences this same issue with HTML fields not
    printing correctly using the Report Builder? What other HTML
    editors besides FCKeditor might we use?
    Thanks,
    Dan VanWieren

    Can you tell me how to use </td> for each values
    Give me your example report - using before or after report
    Thanks
    MT
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by fdenis:
    Hi Gavin,
    If I understand well, your HTML tags are coded directly in your fields in the database, right? Because if it was not the case, you could have use a format trigger checking for which destination you're generating your report...
    if UPPER(:DESFORMAT) = 'HTML' or
    UPPER(:DESFORMAT) = 'HTMLCSS'
    then
    -- insert your HTML code in the value
    -- of your field. something like...
    newValue := '<B>' | | :YOUR_FIELD | | '</B>
    srw.set_field_char( 0, newValue );
    else
    -- when generating to other format,
    -- you'd have to add the formatting as
    -- you want.
    end if
    return( true );
    Of course, if it's not acceptable to remove the HTML tag from your database fields, you could develop a procedure that would translate your HTML tags to the good formatting (eurk... ;-)
    Good luck... :-)
    Frederic
    <HR></BLOCKQUOTE>
    null

  • JLabel with HTML visible only for the first time

    I've implemented a really simple applet:
    public class TestApplet extends JApplet {
      @Override
      public void init() {
        try {
          SwingUtilities.invokeAndWait(new Runnable() {
            public void run() {
              JPanel topPanel = new JPanel();
              topPanel.setLayout(new BorderLayout());
              getContentPane().add(topPanel);
              JLabel labelHello = new JLabel("<html>Hello World!</html>");
              topPanel.add(labelHello, BorderLayout.NORTH);
              JLabel labelHelloNoHTML = new JLabel("Hello World - without html!");
              topPanel.add(labelHelloNoHTML, BorderLayout.SOUTH);
        } catch (Exception e) {
          System.err.println("Couldn't initialize GUI");
    }And there are two html pages, both having the same applet and a link referring to each other:
    index.html
    <html>
           <head><title>Applet</title></head>
           <body>
                  <div><a href="link.html">Link</a></div>
                  <div>
                        <applet hspace="0" height="375" align="left" width="600" vspace="0" mayscript="" alt="GetJava" codebase="./"
                        code="com.test.TestApplet" name="TestApplet"></applet>         
                  </div>
           </body>
    </html>link.html
    <html>
           <head><title>Applet</title></head>
           <body>
                  <div><a href="index.html">Link</a></div>
                  <div>
                        <applet hspace="0" height="375" align="left" width="600" vspace="0" mayscript="" alt="GetJava" codebase="./"
                        code="com.test.TestApplet" name="TestApplet"></applet>         
                  </div>
           </body>
    </html>Now when I navigate to index.html the applet shows correctly both labels but in case I jump to link.html the applet shows only the second label i.e. Hello World - without html! . This seems to be specific to Java version 1.6.0_21 and 1.6.0_22, it was working properly in 1.6.0_17. Is anyone else experiencing similar issue or am I missing something?
    Edited by: user13135196 on Nov 25, 2010 4:33 AM
    Edited by: Slavek Tecl on 25.11.2010 13:12

    I am having this exact same issue. I have a JLabel with <html> for superscript in my JApplet. The first time I run my applet it displays fine. All subsequent times (refresh the page, or close the tab then open again) the JLabel with <html> doesn't show. This issue does NOT occur in the Eclipse Applet Viewer, but does occur with Google Chrome9 and IE8.
    I spent forever checking my methods and changing things trying to figure out why all the other labels show. Never would have guessed <html> in a JLabel would make it not display. This is terrible bug. Please fix ASAP.

  • How to display HTML formatted text in the field with Item Style: Raw Text

    How can I display HTML formatted text in the field with Item Style: Raw Text.
    Currently the Item Style is Raw Text, but the text is being displayed along with HTML tags without formatting.
    Regards

    Hi,
    Use Item Style formattedText.
    Regards,
    Gyan

  • Javafx 1.3 with swinglabel displaying html formated texts

    Dear FX experts,
    I am using swinglabel to display html formated text, and it worked fine with the fx 1.2. However, as I moved to 1.3, the showing of the text is not so proper, because I want the content of the swinglabel be shown in the middle of the box(the label itself) I set. However, in 1.2 it's ok, but 1.3 gives me headache: it's not shown on the place it should be, like it's ignoring all the centering attribute I tried to declare...
    any ideas? or suggestions? or solution?
    (ps, it keeps saying a warning if I used the class under ext package, since swingLabel is under ext... maybe it means I can use another class to do this? but I can't find any...)
    my codes would be like the followings:
    public def contentLabel: SwingLabel = SwingLabel {
    text: "<html\><font size=6>test test</font></html>"
    width: 400
    height: 500
    horizontalAlignment: SwingHorizontalAlignment.CENTER
    public function run(){
    Stage {
        title:"test"
        scene: Scene {
             width: 800
             height: 600
             content: [contentLabel]
    }Edited by: 880613 on 20.08.2011 16:41
    Edited by: 880613 on 21.08.2011 05:13

    No one knows about this?
    the SwingLabel or all Class files under ext packages are simply going to be replaced but without substitutors???

  • How Do I Display HTML Formatted Text From A Data Table In Crystal Reports?

    I'm creating reports in Crystal XI.  The information being displayed in the reports comes from data tables where the text is formatted in HTML.
    I've worked with Crystal Reports enough to know that HTML text pulled from a data table doesn't appear in Crystal the same way it does in a web browser.  Crystal Reports ignores all the tags (...unless I'm missing something...) and just displays the text.
    Someone far more Crystal savy than I (...who I don't have access to...) came up with a Formula Field workaround that tricks Crystal Reports into displaying some basic HTML tags.  Here's that workaround:
    <!--
    stringVar TableName := ;
    TableName := Replace (TableName, "<ul>","<br> <br>");
    TableName := Replace (TableName, "<li>", "<br>   &bull; ");
    TableName := Replace (TableName, "</li>", "");
    TableName := Replace (TableName, "</ul>","<br> <br>");
    TableName := Replace (TableName, "<a", "<u><font color='blue'");
    TableName := Replace (TableName, "</a>", "</font></u>");
    TableName
    -->
    QUESTION - Does any similar workaround exist so I can display an HTML Table in Crystal Reports?  If not, is there any way to display HTML formatted text from a data table in Crystal Reports as it would appear in a web browser?

    Hi Steven,
    To display html text in Crystal Reports follows these steps.
    1. Right click on the field and select Paragraph tab.
    2. Under 'Text Interpretation' select 'HTML Text' and click OK.
    I have tried using the way,but it never works.So reply me if there is any way to solve the issue

  • Doesn't play songs, "itunes is not configured for use with mac-formatted"??

    Hi, new ipod shuffle. Seems to charge fine, all indicator lights function as expected. Everything looks fine in itunes. But it doesn't play songs. I have the most recent versions of itunes and the ipod software. Re-set, updated, and restored, nothing works. Even restored using the restore utility. Re-started computer. Checked for volume control. Won't play songs. Tried different file types. Songs play fine from itunes library and from the device's library within itunes. Tried different headphones. Hooked it up to computer speakers. Turning volume all the way up on device and speakers, heard some very faint rhythmic static, so my guess is the jack socket (or whatever you call it) is just messed up, but it seems weird that it can transfer power and data to the device but doesn't work for sound...
    The only other issues that have come up is that the drive disappears in explorer once it syncs with itunes. Other people who've noticed this seem to have completely different problems so I don't think it's related.
    Also, I have MacDrive on my computer. And when it starts up with the ipod plugged in, MacDrive offers the message "Itunes is not configured for use with Mac-formatted ipods." It offers to automatically reconfigure itunes so it can read mac-formatted ipods. Since I've restored the device, I don't see why formatting should be an issue so I say "no."
    Should I try letting macdrive do its format thing? Should I try formatting the ipod disk on the My Computer menu? Or should I just email apple and tell them the jack's busted?
    Thanks for any thoughts!

    Well, I have had my iPod for about 3 years, it is a 4th generation non-video 40 GB. One day it just stopped working, and now it does not play any songs. when I turn it on it makes this odd whirring sounds that computers make when they try really hard to do something. I cannot charge it, and it is not recognized by iTunes. Also when I turn it on, I get the apple.com/ipod/support (or whatever it is) screen. Needless to say, my warranty is expired, and so I cannot do anything for it except get a new battery, or buy a new one. Is there any way to fix this problem, or anyone out there who is experiencing the same thing?
    I'm having the exact same problem with my wife's iPod. However it will play about 3 seconds of a song and go onto the next song.
    If there is anyone out there that can help please do!
      Windows XP  

  • Send Email with HTML format in Outlook Macro

    I can use the following to send email with HTML format in VBA. I also have created an HTML file. Is there a way to load the file into .HTMLBody to send it as HTML format message?
        Set OutlookApp = CreateObject("Outlook.Application")
        Set objMail = OutlookApp.CreateItem(olMailItem)
        With objMail
           .BodyFormat = olFormatHTML
           .HTMLBody = "<HTML><BODY>Enter the message text here. </BODY></HTML>"
           .Display
        End With

    Try: 
    Dim fso As Scripting.FileSystemObject
    Dim htmlFile As Scripting.TextStream
    Set fso = New Scripting.FileSystemObject
    Set htmlFile = fso.OpenTextFile("C:\path\to\my-html-file.htm")
    strInsert = htmlFile.ReadAll
    then change:
    .htmlbody = strInsert
    oh, and you need to set a reference to the Scripting runtime in Tools, References. 
    Diane Poremsky [MVP - Outlook]
    Outlook & Exchange Solutions Center
    Outlook Tips
    Subscribe to Exchange Messaging Outlook weekly newsletter

  • Help with displaying formated text

    I need some advice in displaying the results from my program. I recieve these results from a CGI program and then display it. I can format how the CGI outputs the text however I want, but in an attempt to make it look nice I have the CGI output html syntax and place my data in nice tables. This text I then send to a JEditorPanel and tell it the text type is html. But there are two problems. The first is, that the results look terrible. It places huge spaces between lines of text, the text is formated bad and at the beginning is the text "head", and "/head" inside of two boxes. The thing is though, if I view this same text straight in Netscape it looks great, but whatever HTML I send to the JEditorPanel looks terrible. Is there a way to improve its results or is there another , better thing to use than the JEditorPanel or a better way to use the JEditorPanel that will allow me to create a pretty, formated text output?

    This was an old post of mine and I don't remember exactly how I was trying to do it, but the problem was just something with the way I was setting up my JEditorPane.
    Now I declare it like this:
         javax.swing.JEditorPane ResultsDisplay = new javax.swing.JEditorPane();
         JScrollPane ResultsDisplayScrollPlane = new JScrollPane(ResultsDisplay);
         HTMLEditorKit htmlEdKit = new HTMLEditorKit();And I do this to set it up during initialization:
              ResultsDisplay.setEditable(false);
              ResultsDisplay.setEditorKit(htmlEdKit);
              ResultsDisplay.setContentType("text/html");
              ResultsDisplay.setEditorKitForContentType("text/html", htmlEdKit);and this during run time to display my HTML formated text:
                   Document doc = ResultsDisplay.getEditorKit().createDefaultDocument();
                   ResultsDisplay.setDocument(doc);
                   System.out.println(inputLine);
                   ResultsDisplay.setText(inputStore.toString());
                   getContentPane().validate();
                           getContentPane().repaint();some of this could be redundant, but it works.
    But are you sure you don't want the dukes? They're stuck to this question and I don't know what else to do with them

  • How can I send email from an JSP page  with HTML format either using jsp

    hi,
    I have an jsp page with online application form,after compleating the form if i select submit it will send all the compleated data to the mail id we mentioned in the form tag,for this i am using javascript,but instead of receiving the data in the format of strings,my client want to receive the data in the same format as he's filling in the jsp page(html format) through e-mail.any help would be appreciated.the fallowing is the code right now i am using for email application.
    <code>
    function send()
    if(validatePersonalInfo(document.theform))
         document.theform.submit()
         location.href=location.reload()
    function validatePersonalInfo(form)
         var tmpStr ="";
         if (form.Name.value == "") {
              tmpStr = "Name";
              document.all.dName.style.visibility="visible";
              document.theform.Name.focus();
         else{
              document.all.dName.style.visibility="hidden";
         if (form.SSN.value == "") {
              tmpStr = tmpStr + ", Social Security Number";
         document.all.dSSN.style.visibility="visible";
         if(form.Name.value != "")
              {document.theform.SSN.focus();}
         else{
              document.all.dSSN.style.visibility="hidden";
    if (tmpStr == "") {
              return true;
         } else {
              alert("Please Fill the Following Fields: " + tmpStr);
              return false;
    <FORM NAME="theform" METHOD="post"
    ACTION="mailto:[email protected]?subject=Online Application Form for MinorityDealer." ENCTYPE="text/plain">
    <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="10" NOF="LY">
    <TH>
    <P>
         <FONT SIZE="3" FACE="Arial,Helvetica,Univers,Zurich BT">Online�Application</font></TH><BR>
    </TABLE>
    <table width="718" border="1" cellspacing="0" cellpadding="3" bgcolor="#CCCCFF" align="center">
         <tr>
    <td colspan="2"><font class="captionText">Name*�</font><br><input type="text" size="25" name="Name" class="bodyText">
    <div id="dName" name="dName" style="position:absolute;visibility:hidden"><font color="red">Name is Mandatory*</font></div>
    </td>
              <td colspan="2"><font class="captionText">Social Security Number*�</font><br><input type="text" size="9" name="SSN" class="bodyText">
              <div id="dSSN" name="dSSN" style="position:absolute;visibility:hidden"><font color="red">SSN is Mandatory*</font></div></td>
    </tr>
    <tr>
    <td colspan="2"><font class="captionText">Total Personal Assets</font><br><input type="text" size="10" name="TotPersAss3" class="bodyText"></td>
              <td colspan="2"><font class="captionText">Total Personal Liabilities & NetWorth</font><br><input type="text" size="10" name="TotPerLiab3" class="bodyText"></td>
    </tr>
         </tr>
    </TABLE>
    <IMG Valign="middle" name="imgSubmit" src="images/buttons/Submit.gif" width="66" height="29" border="0" alt="Submit">
    </code>

    Can any one do some help to solve this problem.
    Regards.

  • Need help with adding formatted text and images to Crystal Report?

    Here's my scenario:
    I have a customer statement that's generated as a crystal report and that has a placeholder for advertisement. The advertisement is mixture of formatted text and images. Until now we only had one advertisement that was always used on the report. The new requirement is that we would have a pool of hundreds of advertisements and would need to display one specific advertisement on the customer statement based on various marketing criteria. They key is that the advertisement content will be determined programmatically and cannot be hardcoded into the report. I'm using Crystal2008 with .net SDK.
    Here are the solutions I thought of, but I'm still rather lost and would appreciate your help/opinion.
    1) Pass HTML or RTF to the report
    Not really sure if this is possible and how to get it done. Also how would I pass in images? Would display formatting be reliable when exporting to PDF?
    2) Create each add as a subreport and append it programatically
    I actually have this working, but I only know how to append a new section to the end of the report and then load the subreport to the section. I have no other controll of the placement. Is there a way to dynamically load a subreport to a predefined section in the main report? How about adding a dummy subreport in the main report as a placeholder and then replacing it with a different subreport? How could I do this?
    3) Pass an Image to the report
    I would create each advertisement as an image and then would somehow add the image to the report. How would I load the image and control the placement? Could I somehow define a placeholder for the image in the main report-maybe a dummy image to be replaced?
    Thank you.

    Hello Pavel,
    I would got the third way.
    You can use dynamic images in your report.
    Just by changing the URL to the image the image can be changed.
    Please see the [Crystal Manual|http://help.sap.com/businessobject/product_guides/cr2008/en/xir3_cr_usergde_en.pdf] and search for images.
    or directly here
    [Setting a Dynamic Graphic Location Path on an Image Object|https://boc.sdn.sap.com/node/506]
    [Dynamic image and HTTP://|https://boc.sdn.sap.com/node/3646]
    [codesample for .NET|https://boc.sdn.sap.com/node/6000]
    Please also use
    [Crystal Reports 2008 SDK Documentation and Sample Code|https://boc.sdn.sap.com/developer/library/CR2008SDK]
    [Crystal Reports 2008 .NET SDK Tutorial Samples|https://boc.sdn.sap.com/node/6203]
    Hope this helps
    Falk

  • Desktop.mail  Mailto with HTML formatted email

    I'm trying to make my application send an email with an HTML formatted table in the body. I've got the text to be visible in the email, but it doesn't format according to the tags and the tags are visible. HTML email is turned on in the email client.
    I've been searching all over for a solution. Are there some escape characters I need to use? Has anyone been able to do this or have any ideas?
    String html = "<table>";
            for (int x = 0; x < reportTable.size();x++){
                ReporterObject table = reportTable.get(x);
                html = html+"<tr>" +
                        "<td>"+table.getReportDate()+"</td>" +
                        "<td>"+table.getSchoolName()+"</td>" +
                        "<td>"+table.getTeacherSpoken()+"</td>"+
                        "<td>"+table.getGoal()+"</td>" +
                         "<td>"+table.getAchieved()+"</td>" +
                         "<td>"+table.getPercentAchieved()+"</td>"+
                         "<td>"+table.getApproaches()+"</td>" +
                         "<td>"+table.getAppointments()+"</td>"+
                         "<td>"+table.getGIEA()+"</td>" +
                         "<td>"+table.getReport()+"</td>" +
                         "</tr>";
            html = html + "</table>";
    URI email = new URI("mailto", "mailto:?to=" + emailField.getText() + " &SUBJECT=AL Reports &BODY=" + greeting + html + salutation, null);

    Please see
    http://javaalmanac.com/egs/javax.mail/SendApp.html
    for Quintessential Program to Send E-Mail.
    Then substitute line
    msg.setText(content);
    /with this one
    msg.setContent( content , "text/html");
    it should do in simplest form.

  • Email html formatted (Text) printing quality issue on hp 6500a (710a)

    I experience some quality problems printing html formatted mails (not attachments, only standard text). The characters are printed with different free space between every char. There is no special sign or format. It happens from different note/netbooks/iphone.
    Pure email-Text-Printing is ok (same text), Attachment-Printing (word-doc arial text only) is ok (same text).
    The  printer has the actual firmware, alle computers and iphone are uptodate. Reset is no solution. Problems are reproducable on other hp 6500 series printers.
    See attached example

    kaaemm,
    Unfortunately, HTML formatted emails are not currently supported. They may go through and print, but results will vary. Only HTML attachments are supported at this time.
    ============================
    If I have solved your issue, please feel free to provide kudos and make sure you mark this thread as solution provided!
    Although I work for HP, my posts and replies are my own opinion and not those of HP.

  • JTextPane - HTML Formatted text Overlap!!!!!!!!!!

    The formatted text overlaps in the printed sheet, but
    it is displayed correctly in the JTextPane
    Code is below:
    import java.awt.*;
    import javax.swing.*;
    import java.awt.print.*;
    class Test implements Printable {
    static JTextPane pane;
    static public void main(String args[]){
    pane = new JTextPane();
    pane.setContentType("text/html");
    pane.setText("<html>"
    +"<font face=Serif size=-1>plain<b>bold</b>plain</font><br>"
    +"<font size=+0>plain<b>bold</b>plain</font><br>"
    +"<font size=+1>plain<b>bold</b>plain</font><br>"
    +"<font size=-1>...................................plain<b>bold</b>plain</font><br>"
    +"<font size=+0>...................................plain<b>bold</b>plain</font><br>"
    +"<font size=+1>...................................plain<b>bold</b>plain</font><br>"
    +"<font size=-1>.......................................................................plain<b>bold</b>plain</font><br>"
    +"<font size=+0>.......................................................................plain<b>bold</b>plain</font><br>"
    +"<font size=+1>.......................................................................plain<b>bold</b>plain</font><br>"
    +"<font size=-1>@@@@@@@@@@plain<b>bold</b>plain</font><br>"
    +"<font size=+0>@@@@@@@@@@plain<b>bold</b>plain</font><br>"
    +"<font size=+1>@@@@@@@@@@plain<b>bold</b>plain</font><br>"
    +"<font size=-1>@@@@@@@@@@@@@@@@@@@@@@plain<b>bold</b>plain</font><br>"
    +"<font size=+0>@@@@@@@@@@@@@@@@@@@@@@plain<b>bold</b>plain</font><br>"
    +"<font size=+1>@@@@@@@@@@@@@@@@@@@@@@plain<b>bold</b>plain</font><br>"
    +"<font size=-1>plain<i>italic</i>plain</font><br>"
    +"<font size=+0>plain<i>italic</i>plain</font><br>"
    +"<font size=+1>plain<i>italic</i>plain</font><br>"
    +"<font size=-1>...................................plain<i>italic</i>plain</font><br>"
    +"<font size=+0>...................................plain<i>italic</i>plain</font><br>"
    +"<font size=+1>...................................plain<i>italic</i>plain</font><br>"
    +"<font size=-1>.......................................................................plain<i>italic</i>plain</font><br>"
    +"<font size=+0>.......................................................................plain<i>italic</i>plain</font><br>"
    +"<font size=+1>.......................................................................plain<i>italic</i>plain</font><br>"
    +"<font size=-1>@@@@@@@@@@plain<i>italic</i>plain</font><br>"
    +"<font size=+0>@@@@@@@@@@plain<i>italic</i>plain</font><br>"
    +"<font size=+1>@@@@@@@@@@plain<i>italic</i>plain</font><br>"
    +"<font size=-1>@@@@@@@@@@@@@@@@@@@@@@plain<i>italic</i>plain</font><br>"
    +"<font size=+0>@@@@@@@@@@@@@@@@@@@@@@plain<i>italic</i>plain</font><br>"
    +"<font size=+1>@@@@@@@@@@@@@@@@@@@@@@plain<i>italic</i>plain</font><br>"
    +"</html>");
    JFrame frame = new JFrame("Printing test");
    frame.getContentPane().add(pane);
    frame.setSize(600,800);
    frame.setVisible(true);
    PrinterJob job = PrinterJob.getPrinterJob();
    job.setPrintable(new Test(), job.defaultPage());
    if (job.printDialog()) {
    try { job.print(); }
    catch (Exception e) { }
    System.exit(0);
    public int print(Graphics g, PageFormat pf, int pageIndex) throws PrinterException {
    if (pageIndex >= 1) return Printable.NO_SUCH_PAGE;
    Graphics2D g2d = (Graphics2D)g;
    g2d.translate((int)pf.getImageableX(), (int)pf.getImageableY());
    g2d.setClip(0, 0, (int)pf.getImageableWidth(), (int)pf.getImageableHeight());
    try { pane.print(g2d); }
    catch (Exception e) { }
    return Printable.PAGE_EXISTS;
    The bold text overlaps

    I think the textpane wisth has is not adustable to theformatted text to acccomodate

  • It is possible to Display HTML Formatted Text?

    Hi
    This is what I want to accomplish:
    I created a system and now I want to add a help button on each page. This button will open a popup window which will display the help of the current page. (This is done)
    But now I want to display a formated text (plain or html) just like this example:
    h2. Help
    Page 20:
    Description:
    This page displays a list of users.
    And don't like this other:
    Help Page 20: Description: This page displays a list of users.
    Thanks a lot!

    This is still a problem...I'd like to add a bit to it.
    The HTML Editor correctly places formatting tags around the text and the item is saved to the db (or whatever)...however, when displaying the formatted text on an apex generated page, and it doesn't matter what type of DISPLAY (saved, non-saved, escape, etc..) is being used, Apex places <SPAN class="display_only"> around the text in question which is apparently overriding the html tags, so the text displays in the CSS defaults regardless of the formatting used by the HTML Editor. The reason the formatted text displays correctly in a "report" is because this span doesn't exist.
    I'd like to take the time to add a change request and request that item level classes are not buried within apex and the theme. It would be nice if they were displayed on the item, for example, so they could be easily removed or overrided...this span for example overrides even a TD level custom class because of it's placement, so there seems to be little or no way to override it.

Maybe you are looking for

  • How to reverse goods issue for delivery note by using IDoc

    Hi all, I would like to reverse goods issue and picking request for delivery note by using inbound IDoc. I used message type SHPCON and IDoc type DEVLRY03 for posting goods issue in inbound processing and it's work but I couldn't find solution for po

  • Mailing photos as attachments

    When I email photos to friends, I like to see the familiar paper clip for attachments in the header for the email, and I do not like the actual photo stripped into the message. I am not even sure they are sent as attachments. And when I check my Sent

  • Ugly fonts rendering with poppler-qt-lcd

    Hello, These patches don't work on my system. All fonts rendering are beautiful, but pdf documents in okular are ugly. I have tried ubuntu cairo patches without effects on this issue. I have tried also to change hinting parameters in fontconfig witho

  • Print out of JPG attachements

    Hi, I've got Photosmart premium eOIA C310 The printout of attachments formatted as photos e.g. in JPG format is done with paper feeded from photo paper magazine (10x15 ). The file, even of it is JPG file, doesn't need to be a 10x15 photo. Is there an

  • Pagenumber on outside of the page

    I like to print a Pages document in book-style, with the pagenumbers on the outside of the page. So left aligned on the odd pages, right aligned on the even pages. In the previous version of Pages this was possible; I cannot find how to do this in ve