Re: Resize JTextPane to fit HTML content

Where are you getting the HTML from? If you just want it to have a scroll bar you don't have to worry about calculating its size. Just do this.
JScrollPane textScrollPane = new JScrollPane();
textScrollPane.getViewport().add(textArea);
textPanel.add(textScrollPane); now the text area will automatically add the horizontal bar
when the data is larger than the view.

Victor,
In my experience, the Resize command will only be available if something will change if the action is taken. For instance, if you have some text in a cell that is a longer string than will fit in the column, Resize column to fit content should be available. If you click on that command, it will become unavailable, because it now will have no effect if clicked again. If you increase the font size, the row size may increase to fit the new text size. If you reduce the text size, the Fit command will become available for that row. If used, the command will again become unavailable until needed again.
Remember that only selected rows and columns are affected.
Regards,
Jerry

Similar Messages

  • Font color issue with inserted HTML content in JTextPane (HTMLEditor)

    Hi everyone,
    I have a very serious issue with the HTMLEditor I'm developping. This editor is a little bit special since it is intended to edit blocks of HTML content that are loaded when the editor is initialized.
    You can in fact decide to keep this loaded HTML content or start a new HTML document from scratch. Alright, now my issue is the following :
    When text is loaded, it's properly rendered. I have a functionality which let's you see the HTML code from the HTML document used in the editor, so I can check and see if code is correct, and yes, it's correct.
    The problem is that when I try to change the color attribute of some text on my loaded content, nothing happens ! I don't know what's the matter with this bug, I only have it with the color attribute, with every other attribute everything's fine (font, size, etc.)
    The funny thing is that, after I change another attribute for loaded content, like font family, then changing color attribute funcionnality starts to work again !
    I've also noticed that I don't have any of these problems when I start my HTMLDocument from scratch (when I create a new HTML document and start typing text).
    Another weird thing, is that I have a feed-back feature in my editor which reflects attributes for text over which the caret is positionned. For example, if you put caret over red text, the color combo box displays a red value, you know, just like in MS Word. Well, with my loaded content if I have a red text color and I decide to put it in green, the color combo box displays the green value when I click over text for which I have changed color, but in my JTextPane it's still red !! And when I try to see the HTML code generated nothing has changed, everything is still red !
    There is something really strange here, this means that when I get the attributes of the loaded text from the HTMLDocument, color appears to be green, but when it gets rendered in the JTextPane it's still red and when it gets anlyzed to produce the corresponding HTML code, these changed attributes are not taken into account.
    But the most weird thing above all, is that I don't have this bug everytime, sometimes I start my HTML editor applet and it works fine, and some other times this color issue is bakc there. Is this a known bug for Swing API or not ?
    =============
    This is more or less my technique :
    //I declare a global reference to my HTMLDocument
    HTMLDocument _docHTMLDoc;
    //Create a JTextPane
    JTextPane _tpaEditor = new JTextPane( );
    //Set type content to automatically select HTMLEditorKit
    _tpaEditor.setContentType("text/html");
    //Get a referene to its HTMLEditorKit
    HTMLEditorKit _kitHTMLEditor = (HTMLEditorKit) _tpaEditor.getEditorKit( );
    //I then have a function to create new documents
    void newDocument(){
      _docHTMLDoc = (HTMLDocument) _kitHTMLEditor.createDefaultDocument();
      _tpaEditor.setDocument(_docHTMLDoc);
       //I do other stuff wich are not important to be shown here
    //I then have another function to load content
    void loadContent(){
       //I get content from a HashMap I initialized when I started my applet
       String strContent = (String)_mapInitParameters.get("html_content");
       //I set content for my editor
       _tpaEditor.setText(strContent);
    //Notice.. I have tried many other ways to load this text : via HTMLEditorKit and its insertHTML method, I
    //have also tried to store this content in some reader and make HTMLEditorKit read it... and nothing,
    // I always get the bug
    //To change color it goes like this :
    JComboBox _cboColor = new JComboBox();
    //I correctly initialize this combo with colors
    //then I do something like this
    ActionListener _lst = new ActionListener(){
       public void actionPeformed(ActionEvent e){
          Color colSel = (Color) _cboColor.getSelectedItem();
          MutableAttributeSet mas = new SimpleAttributeSet();
          StyleConstants.setForeground(mas,colSel);
          setAttributeSet(mas);
    _cboColor.addActionListener(_lst);
    //Set Attributes goes something like this
    private void setAttributeSet(javax.swing.text.AttributeSet atrAttributeSet) {       
            //Get current 'End' and 'Start' positions
            int intCurrPosStart = _tpaEditor.getSelectionStart();
            int intCurrPosEnd = _tpaEditor.getSelectionEnd();
            if(intCurrPosStart != intCurrPosEnd){
                //Apply attributes to selection
                _docHTMLDoc.setCharacterAttributes(intCurrPosStart,intCurrPosEnd - intCurrPosStart,atrAttributeSet,false);
            else{
                //No selection : apply attributes to further typed text
                MutableAttributeSet atrInputAttributes = _kitHTMLEditor.getInputAttributes();
                atrInputAttributes.addAttributes(atrAttributeSet);

    hi, friend!
    try this:
    void setAttributeToText(JTextPane pane, int start, int end, Color color) {
    MutableAttributeSet new_att = new SimpleAttributeSet();
    StyleConstants.setForeground(new_att,color);
    HTMLDocument doc=(HTMLDocument)pane.getDocument();
    doc.setCharacterAttributes(start,end,new_att,false);
    It works fine in my Application, hope will work in yours, too.
    good luck.

  • How to force a container redraw to fit-to-content?

    Hi,
    This has been driving me crazy for a long time now.
    Example:
    <panel id="outer">
    <panel id="inner">
    <textarea text="blah blah blah"/>
    </panel>
    </panel>
    The above works fine, the outer panel's size perfectly fits
    its content.
    But if the mxml starts out with only the outer panel, and
    then I add the inner panel as result of some user event at a later
    time, then outer panel will not resize to fit. It will be really
    small and just add some scrollbars when the new content is added.
    I've tried several combinations of the following on the
    various elements with no luck...
    container.invalidateDisplayList();
    container.invalidateSize();
    container.validateDisplayList();
    container.validateNow();
    container.validateSize(true);
    Doing these things seem to have no effect. Arrgh.. please
    help!
    Thanks

    Thanks Greg, you are right. It does work. I guess my problem
    was related to the fact that I had a more complex hierarchy of
    containers, including an HDivideBox which apparently will not
    resize. So taking out layout=absolute, and cleaning up my container
    hierarchy seems to have fixed the problem. Your answer got me back
    on the right track.

  • Webkit - Get the size of the html content

    I want to resize the window of my Webkit app so that it snugly fits the content that it is displaying. I know how to resize a window - but I don't know how to get the size of the content I am trying to display. Clearly, webkit knows the size of the content because it can centre the content on the screen and display scrollbars if necessary. How can I get this information?
    I am using Objective-C to write my app.

    The page hasn't finished loading so the preferred size isn't known yet. Check out this thread:
    http://forum.java.sun.com/thread.jsp?forum=57&thread=333171

  • DPS HTML Content

    Hi, I'm trying to use the HTML Content but facing a problem.
    I'm trying to create a interactive content where you can fill some fields (exercises), I hava a javascript file where check your answers and tells if the exercise is right or wrong. The problem is when you touch the fied to fill it up. I made a div with a width of 500px avoid the content to scroll, but its not working. When you touch you can scroll horizontal and vertical.
    Can someone helo me with this issue. Is there a way to fix the content in the InDesign container. PS. i already tried the scale to fit.
    Thanks.

    You can also use this starter framework which prevents scaling bugs in iOS which is likely to happen in your case if you don't have set the correct meta and CSS properties: https://github.com/anselmh/HTML5-DPS-Boilerplate

  • Safari option to resize image to fit window?

    This item has come up here before, but seems to always fizzle out. Did anyone ever find a plugin for Safari that would resize images so that they fit in the browser window?
    The problem is when you try to view pictures that are larger than the screen size, I would like to be able to have my Safari browser automatically resize them to fit the screen. MS Internet Explorer has this feature and I have gotten used to it!
    Randy.

    Geert01 wrote:
    I want to achieve this: Table whith background image but cannot get it to work in an Apex page with HTML region.
    Adding the following code to the html region:
    <table class="tableWithBackground" width="300px" height="200px" border="1">
        <tr>
            <td>
                <img class="tableBackground" src="#APP_IMAGES#Demo.jpg">
                Hello
            </td>
            <td>
                World
            </td>
        </tr>
        <tr>
            <td>How are<br><br><br><br><br>you?</td>
            <td>I am fine</td>
        </tr>
    </td>
    Results in a page with a table but without borders (at his stage I have not yet uploaded the Demo.jpg). After uploading the Demo.jpg results in a table with the entire image placed in het first cell. After placing the class code in the CSS inline property I expected to see the result as is shown in the Table whith background image  demo. For some reason this does not work (the image is no longer visible).
    Can anybody tell me how to achieve my goal?
    This is a workaround. What's your real goal? Why do you want to do this?
    What browser(s)/version(s) are you using? All current browser versions have support for CSS3 background sizing which is the proper way to do this.

  • Report and HTML content

    Hi,
    I have a lot of HTML formatted text stored in a blob field.
    The HTML code has some <b>a href</b> tags (something like this: a href = "53127" or a href = "53127_1" or a href = "53127_2" ...).
    I created a appIication using APEX (10gXE) and I can display the HTML content in my report but the links do not work.
    I need something like this:
    http://127.0.0.1:8080/apex/f?p=103:4:SESSION_ID::NO:RP,:P4_CODACT:53127
    instead of:
    http://127.0.0.1:8080/apex/53127
    I am tryng to migrate a web application created in Java using servlets. In Java the solution was the use of regular expressions to convert the stored <b>a href</b> tag to a valid url.
    Here is my Java code:
    -- some code
            s=processHtmlTags(s,
                "<a href = \"([0-9_].*?)\">",
                "<a href=\"" + dm.response.encodeURL("ResultDetail") + "?codact=",
                "\">");-- rest of servlet
    -- the processHtmlTags definition
        public String processHtmlTags(String INPUT, String REGEX, String strHead, String strTail) {
            int cnt=0;
            String strOutput;       
            Pattern pattern;
            Vector group0 = new Vector(5);
            Vector group1 = new Vector(5);       
            try {
                pattern = java.util.regex.Pattern.compile(REGEX);
                matcher = pattern.matcher(INPUT);
            catch(java.util.regex.PatternSyntaxException pse) {
            while (matcher.find()) {           
                group0.addElement(matcher.group(0));
                group1.addElement(matcher.group(1));
                cnt++;
            strOutput=INPUT;
            for(int i=0; i<group0.size(); i++) {           
                String s0=(String)group0.elementAt(i);
                String s1=(String)group1.elementAt(i);
                strOutput=strOutput.replaceAll(s0,strHead+strAnchor(s1)+strTail);           
            return strOutput;
        }The question is can I do the same thing using APEX?
    Thanks,
    Catalin Florean.

    Use the REGEXP_REPLACE function available in 10g.
    That also implies switching from an HTML region to a PL/SQL region.

  • SSRS 2008 R2 report does not print the page header for a html content displaying on multiple pages

    Hi
    I need to display the html content from the database. The html content are quite long and can have content of 3-5 pages. Issue I  am facing is f the record has html content of 3-5 pages, then it does not print the page header (which is a separate tablix) on
    second page onwards.
    Nikesh Shah
    Nikesh Shah

    Hi Nikesh,
    According to your description, I’m not sure the meaning of Page header in your scenario. In Reporting Services, a page header that run along the top of each page, respectively. Headers can contain static text, images, lines, rectangles, borders, background
    color, background images, and expressions. But we couldn’t add tablix in the page header.
    If you are saying report header, a report header consists of the report items that are placed at the top of the report body on the report design surface. They appear only once as the first content in the report. So it cannot repeat in other pages.
    If you are saying tablix header, freezing column headers are different in table and matrix. For more details, please refer to the following thread:
    http://social.technet.microsoft.com/Forums/sharepoint/en-US/c8ddc1af-1bdf-4e72-8aab-0353c7cc848a/ssrs-report-freezing-row-and-column-while-scrolling-issue?forum=sqlreportingservices
    If there are any misunderstanding, please elaborate the issue for further investigation.
    Regards,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • Print html content of an JEditorPane

    Hello!
    I have an JEditorPane with some HTML Content displayed (as it is displayed in a browser).
    Now i want to sent this content to a printer.
    After some search i found the DocumentRenderer class from this link:
    http://www.fawcette.com/javapro/2002_12/online/print_kgauthier_12_10_02/
    It may be trivial, but i don't know how to create a HTMLDocument Object from my JEditorPane (and its contents).
    Maybe somebody can help me out with this.
    my code so far:
    DocumentRenderer renderer = new DocumentRenderer();
    HTMLDocument doc = new HTMLDocument();
    //At this point i don't  know how to get my JEditorPane/it's contents "into" the HTMLDocument Object
    renderer.setDocument(doc);
    renderer.print(doc);                               Many thanks in advance for help!

    find it out by myself.
    HTMLDocument doc = (HTMLDocument)myJEditorPane.getDocument();But now i ran in another problem:
    Checkboxes are not displayed when i print this content.
    Is it possible to solve this problem?

  • SSRS 2008 R2 report prints empty spaces for html content till end of page

    Hi
    I need to display records containing long html content say each record of different size ranging from 5 lines to 3-5 pages.
    Issue observed is:
    When a record complete is printing say half the page and subsequent record is bigger then half a page, the subsequent record is printed on the next page rather than continue immediately after the previous record is completed.
    Is their any property or any other solution to resolve the issue. Print on next page is not set.
    Nikesh Shah

    Hi Nikesh,
    As per my understanding, I think the issue is caused by the blank space in the report body. In order to get rid of the blank space when print the report, please refer to the following steps:
    Click on Report > Report Properties > Layout tab
    Make a note of the values for Page width, Left margin, Right margin
    Close and go back to the design surface
    In the Properties window, select Body
    Click the + symbol to expand the Size node
    Make a note of the value for Width
    Please check the Page Break settings on all your report items and make sure the Body Width + Left margin + Right margin less than or equal to Page width, just like the equalities below:
    (Body Width + Left margin + Right margin) <= (Page width)
    If there are any other questions, please feel free to ask.
    Regards,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • HTML Content not displayed correctly in UWL

    Hi all,
    I have setup UWL to connect to SRM 5.0 system. I have no problem retrieving alerts from the backend. However, alerts with HTML content are not displayed correctly in the UWL. Instead of parsing the HTML content, the html tags are displayed instead.
    Am I missing some configurations here?
    Thanks in advance.

    Hi Benny;
    Please see:
    My Oracle Support FAQ [ID 747242.5] << What are the browser requirements for accessing My Oracle Support?
    If you have still problem you can go wiht SR
    Regard
    Helios

  • HTML Content in Email Notifications

    Hi
    I was wondering if HTML content is supported in BPM Email notifications. The html code in the BPM UI task email notification is coming as plain HTML in the email, can you please let me know if there is any flag that needs to be turned on to process the HTML code before the email is sent out?
    Thanks
    Sasi

    i think standard notification doesn't support this.

  • Best practice for sharing html content on different group spaces?

    How can html content be shared between several group spaces?
    One way I have found is to add a html doc to ucm and then to add this doc as a iframe to a page.
    Are there other ways, like adding on one group space page a html layout element and then to view this content in a different space. How could this be done, with an expression language reference?
    Has someone experience in presenting the same html content on different spaces and can share how he does it. Any ideas are welcome.
    Thanks,
    Max

    Hey Max,
    Check out our technical whitepaper on Integrating ECM with Portal Technologies.
    Our "Fishbowl Portlets" allow you to share any content - HTML, WYSIWYG user generated content, documents etc - in multiple contexts (portlets, web apps, etc).
    This is one of the things that we showcased as the recent Collaborate conference in Vegas - WebCenter framework, UCM and the portlets surfacing the same items in different contexts - all personalization aware, configurable and end user/super user editable.
    The white paper can be found here:
    http://www.fishbowlsolutions.com/StellentSolutions/ContentManagementResources/index.htm
    A blog post on it can be found here:
    http://cfour.fishbowlsolutions.com/2010/03/10/fishbowl-portlets-followup-cis-and-content-consumption-options/
    warmly,
    Billy Cripe
    Fishbowl Solutions

  • How to attach HTML content to DMS Document?

    Hello,
    I have a requirement in which I have to make a HTML file which contains the current Dispaly on screen, I have to attach this HTML file inside the DMS document.
    For this I am doing following steps.
    1 ) FM SAVE_LIST
    2) FM WWW_HTML_FROM_LISTOBJECT, form this FM I am getting the Internal table which is containing the HTML content.
             a) I am converting this internal table content ot first in XSTRING using FM SCMS_TEXT_TO_XSTRING
             b) And XSTRING to Binary format.
    3) After this I am creating a DMS cocument using FM CVAPI_DOC_CREATE
    3) After DMS document creation I am using FM CVAPI_DOC_CHECKIN to attach HTML file content to this DMS Document.
    Everthing seems to be ok, but when I am using CV03N to view the document, its showing the HTML file bu not showing the original content(HTML)
    Please help to find the problem, Is there any other way from which I could CHECKIN HTML content directly inside DMS document in HTML form without converting it to binary.

    HI,
    I have not understood the requirement.
    As far as I know, HTML need not to be checked in.
    Refer also link below
    Re: some questions on SAP DMS
    May be useful in choice of FM.
    Regards
    Nitin

  • HTML content with images and links blocked

    Hello,
    I very much need some help here because my company needs to send out newsletters to our clients in HTML format soon and so far the email with HTML content is being blocked as spam while text content works fine. Specifically, whenever I add a link or an image in HTML content, the email doesn't go through. I tried sending in multipart format but it is also not sending HTML with images and links. Here is my attempt:
                                    props.setProperty("mail.transport.protocol", "smtp");
                                     props.setProperty("mail.host", "mail.server.com");
                                     props.setProperty("mail.user", "joeuser");
                                     Session mailSession = Session.getDefaultInstance(props, null);
                                     mailSession.setDebug(true);
                                     Transport transport = mailSession.getTransport();
                                     MimeMultipart mp = new MimeMultipart("alternative");
                                     MimeBodyPart htmlPart = new MimeBodyPart();
                                     MimeBodyPart textPart = new MimeBodyPart();
                                     textPart.setText("Just to make it multipart");
                                     htmlPart.setHeader("MIME-Version", "1.0");
                                     htmlPart.setHeader("Content-Type", htmlPart.getContentType());
                                     htmlPart.setContent(strHtmlMessage, "text/html");
                                     mp.addBodyPart(textPart);
                                     mp.addBodyPart(htmlPart);
                                     MimeMessage message = new MimeMessage(mailSession);
                                     message.setHeader("MIME-Version", "1.0");
                                     message.setHeader("Content-Type", mp.getContentType());
                                     message.setHeader("X-Mailer", "Recommend-It Mailer V2.03c02");
                                     message.setContent(mp);
                                     message.setSubject(strSubject);
                                     message.setFrom(new InternetAddress("[email protected]"));
                                     message.addRecipient(Message.RecipientType.TO,
                                             new InternetAddress("[email protected]"));
                                             transport.connect();
                                             transport.sendMessage(message,
                                             message.getRecipients(Message.RecipientType.TO));
                                     transport.close();This code is one of my numerous attempts to make HTML send images and links. Please, let me know if there is a workaround way to make JavaMail send HTML with links and images in the message body. Your help will be greatly appreciated.

    The JavaMail FAQ has information on creating HTML messages, including
    messages with both plain text and HTML. Did you find it?
    BTW, your code has many unnecessary statements, such as setting
    the Mime-Version header, which JavaMail will do for you, and setting
    the Content-Type header, which JavaMail does as a side-effect of the
    setContent or setText calls.
    Other than that, it looks like your code should be correctly creating a
    multipart/alternative message. If the recipient is still rejecting it you
    need to figure out what it is about the message that makes the recipient
    think it's spam. Can you send a similar message using another mailer?
    Can you send the message to a different recipient?

Maybe you are looking for

  • Bursting program errors when no data - Check output before bursting

    Hello experts, I have a XML Publisher Report with a Data Template + Bursting Control File. This works perfectly when there is data. But, when there is no data, main concurrent program completes successfully but the Bursting concurrent Program errors.

  • ZIP attachments in PDF file

    How can ZIP files be opened from a PDF file using Preview. First, how can you see attachments within Preview, and then, how can it be opened.

  • Text Export vs XML file

    If I do Select All, and then Export and save as a .txt file, does the resulting file contain all the same key info as the iTunes library .xml file? Situation is, two users, me and Mrs. Helmet. All music stored in folder on dedicated media drive. Howe

  • Username and Password access oracle 10g

    I have recently insalled oracle10g. Throughout the installation process they were no requirements to specify a username and password, hence I am having trouble logging into the enterprise manager console. Can anybody help?? Thanks Rich

  • Help with .atn files

    where do i put the .atn files that i just downloaded from the exchanges