JEdtiorPane/HTMLEditorKit word wrapping problems

Hi,
I have a JFrame component that has a splitPane, on the left side is a JTree and the right side has a JEditorPane that has it's content updated with HTML using a method to generate the HTML via the setText() method . (no url, and no html file)
The searching I did indicates that word wrapping is the default behavior, and I saw a lot of posts from people trying to get rid of the word wrapping, but it isn't wrapping at all for me. I get the horizontal scroll bar.
I had the same problem using a JTextPane...anyone know how to wrap text?
here's the relevant code:
descriptionPanel = new JPanel(new BorderLayout());
          descriptionEditorPane = new JEditorPane();
          HTMLEditorKit htmlEditorKit = new HTMLEditorKit();
          descriptionEditorPane.setEditorKit(htmlEditorKit);
          descriptionEditorPane.setSize(new Dimension(610,800));
          descriptionEditorPane.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
          descriptionPanel.add(descriptionEditorPane);

Did you place the components into scroll panes and then put those into the split pane?
If so, then I guess that calling setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER) on the editor pane's scroll pane might solve your problem.

Similar Messages

  • Word wrap problems in 36.0

    When entering text into a web form the text no longer "wraps" at the end of the box. The first part of the text runs off the left side. It is working fine in THIS text entry box but is now a problem on some other sites.
    See: http://www.thedirectoryclassifieds.com. Start placing a listing and then start entering text into the description box. Once you reach the end of the line the text does not wrap, just runs off the left side as typing continues. After this testing, just exit (back out) without continuing placing the listing.
    When encountering this problem I did a test on another computer that had 35.0.1 and word wrapping worked fine. Then I upgraded to 36.0 on that computer and now the problem is there too.
    So this definitely means a problem with 36.0 as it wasn't there in earlier versions.

    That particular form control has:
    <textarea id="main_description" name="b[description]" '''style="white-space: pre;"''' class="editor field"></textarea>
    For the first time in Firefox 36, the white-space property is being honored for textarea controls. So there's your trouble: "pre" means Firefox should emulate the preformatted tag, which requires manual line breaks.
    It would be great if you can convince the site to change this to:
    &lt;textarea id="main_description" name="b[description]" '''style="white-space: pre-wrap;"''' class="editor field"></textarea>
    which is supported by all modern browsers (per the compatibility table here: [https://developer.mozilla.org/docs/Web/CSS/white-space#Browser_compatibility]).
    But that likely will take some time, so what is the best short-term workaround? I need to think about that a bit.
    To manually hack this form control, you can right-click it and choose Inspect Element (Q). This should open the web console to the Inspector in the lower part of the tab. Firefox should highlight the HTML tag I listed first above, and on the right, show the style rules for it. Under "This Element" you can uncheck the box for that rule to have the textarea styled using default rules. But you would need to do this after each time you load the page, which is a hassle.

  • JEditorPane word wrap problems

    I am using a JEditorPane in a chat window that is used, like instant messenger, between two clients. The ability to insert icons and different fonts is available after setting the editor kit to an HTMLEditorKit. However, after using an HTMLEditorKit, the word wrapping is a bit funky in that the words are cut off when wrapping.
    Is there any way to get aroudn this while STILL using a JEditorPane (or something similar that can accept HTML?). I would be able to use JTextPane, which wraps correct (I believe...I'm trying to think back to my first implementation), but the icons begin to get tricky there. I know how to insert them, but if I have multiple icons, I would need to find all of the first occuring icons since the string needs to be printed immediately to the screen.
    Thanks for any help.

    I don't have an HTML document. Maybe you are mis-interpreting what I am trying to do :)
    I am implementing a simple instant messenger (much like AIM). Right now, I have a JEditorPane that is using an HTMLEditorKit to render HTML. This is used to display emoticons and also change the font and font color. So, the HTML I am generating is manually put in there in the code so text will show up differently - say, the senders name will be red and the recipient will be blue.
    Everything is working fine, except the text is wrapping and words are being cut off. In other words, this is happening:
    | This is an exa |
    | mple of some |
    | thing that is ha |
    | ppenning in m |
    | y chat window. |
    -----------------------

  • Livecycle Designer 8.0 word wrap problem

    Here is the link to the application I made
    http://www.nevadajudiciary.us/index.php/view-documents-and-forms/func-startdown/309/
    I am using Full* with script xfa.host.setFocus("FieldName"); to get my form to word wrap, but it is cutting off a letter before it does the word wrap to the next line.  Is there any way to not orphan that letter and just move to the next line?  Is there some better script out there for what I am trying to do?

    You are asking for a world of hurt if you try and handle the word wrap yourself. Not to mention the movement from one line to the next.
    Is there anyway you can change their minds? That technique is more in tune with a printed form as opposed to an online ffillable orm.
    Paul

  • Force word wrap in JTextPane (using HTMLEditorKit)

    Hi!
    I have a JTextPane on a JScrollPane inside a JPanel. My text pane is using HTMLEditorKit.
    I set the scrolling policies of my JScrollPane to: JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED & JScrollPane.HORIZONTAL_SCROLLBAR_NEVER.
    I did not find in JTextPane�s API any relevant property I can control word-wrapping with (similar to JTextArea�s setLineWrap) and I have tried a few things to force word-wrapping but nothing worked...
    What happens is my text is NOT being wrapped (even though there is no horizontal scrolling) and typed characters (it is an enabled editable text componenet) are being added to the same long line�
    I�d like to force word-wrapping (always) using the vertical scroll bar whenever the texts extends for more then one (wrapped) line.
    Any ideas?
    Thanks!!
    Message was edited by:
    io1

    Your suggestion of using the example only holds if it fits the requirements of the featureDid your questions state anywhere what your requirement was?
    You first questions said you had a problem, so I gave you a solution
    You next posting stated what your where currently doing, but it didn't say it was a requirement to do it that way. So again I suggested you change your code to match the working example.
    Finally on your third posting you state you have some server related issues causing the requirement which I did not know about in my first two postings.
    State your problem and special requirments up front so we don't waste time quessing.
    I've used code like this and it wraps fine:
    JTextPane textPane = new JTextPane();
    textPane.setContentType( "text/html" );
    HTMLEditorKit editorKit = (HTMLEditorKit)textPane.getEditorKit();
    HTMLDocument doc = (HTMLDocument)textPane.getDocument();
    textPane.setText( "<html><body>some long text ...</body></html>" );
    JScrollPane scrollPane = new JScrollPane( textPane );If you need further help then you need to create a [url http://homepage1.nifty.com/algafield/sscce.html]Short, Self Contained, Compilable and Executable, Example Program (SSCCE) that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.
    And don't forget to use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags so the code retains its original formatting.

  • I have been using a Google moderated group with a robo receptor which suddenly turns down my message submission because it won't "word wrap" correctly. I have made no changes in my messages to the forum so the problem must be with my end. Any Ideas?

    I have been using a Google moderated group with a robo receptor which suddenly turns down my message submission because it won't "word wrap" correctly. I have made no changes in my messages to the forum so the problem must be with my end. Any Ideas?

    I have been using a Google moderated group with a robo receptor which suddenly turns down my message submission because it won't "word wrap" correctly. I have made no changes in my messages to the forum so the problem must be with my end. Any Ideas?

  • Read Only TextAreas with Carriage Return, Line Breaks and Word Wrapping

    Hi all,
    I know there are a few posts around this subject but I cannot find the answer to the exact problem I have.
    I have a page that has a 'TextArea with Character Counter' (4000 Chars) that is conditionally read only based on the users credentials (using the 'Read Only' attributes of the TextArea item).
    When the field is editable (not Read Only) everything works fine but when I make the field Read Only I start to have problems:
    The first problem is that the Carriage Return and Line Breaks are ignored and the text becomes one continuos block. I have managed to fix this by adding pre and post element text of pre and /pre tags. This has made the Carriage Return and Line Breaks word nicely and dispaly correctly.
    However, it has introduced a second problem. Long lines, with no Carriage Returns or Line Breaks, now extend to the far right of the page with no word wrapping, making my page potentially 4000+ characters wide.
    How can I get the field to be display only, with recognised Carriage Returns and Line Breaks, and Word Wrapping inside a fixed width of, say, 150 characters?
    Many thanks,
    Martin

    Hi,
    Just a cut and paste of yours with the field name changed:
    htp.p('<script>');
    htp.p('$x("P3_COMMENTS").readonly=true;');
    htp.p('</script>');I also have the following in the page HTML Header, could they be conflicting?
    <script type="text/javascript" language="JavaScript">
    function setReleaseToProd(wpTypeCode){
       //setReleaseToProd($v(this))
      var get = new htmldb_Get(null,$v('pFlowId'),'APPLICATION_PROCESS=set_release_to_prod',0);
      get.addParam('x01',wpTypeCode);
      gReturn = get.get();
      if(gReturn) {
         $s('P3_RELEASE_TO_PROD',gReturn);
      get = null;
    </script>I am a long way from knowing much about Javascript (this page code was written by someone else) so all help is much appreciated.
    Martin

  • Text area and Word Wrapping

    I am creating a email form and am having problems with word
    wraping in the text area. You can view the page and the output if
    you put your email address in the form. The problem is the text
    areas word wrap when inputting your information but all formatting
    is lost in the email. Even if I add spacing for paragraphs. All
    data is just a big run on sentence.
    Here is the
    Page.
    I am using Dreamweaver * and php.
    Thanks

    Someone may have tried this because I received this output in
    an email. You can see the formattint is lost.
    Gear Ad:
    Description:
    This is a test. Line 1 Line 2 Line 3 Line 4 -
    Test...test...test...test...test...test...test...test...test...test...test...test...test. ..test...test...test...test...test...test...test...test...test...test...test...test...test ...done!
    Price:
    test
    Contact:
    This is a test.

  • [Solved]Conky and word wrapping - Is there a way?

    So I have a very limited area to work with, something like 176x360 (+/- a few pixels), and I want the ability to show an RSS feed. Well, the feed works of course, but due to the limited width, I'm in great need of word wrapping, and for that problem I have found no solution and going on for 2-3 hours straight, my head hurts
    Anyway, here's my .conkyrc, not that it's needed of course.
    # ~/.conkyrc
    double_buffer yes
    use_xft yes
    xftfont Bitstream Vera Sans Mono:size=8
    xftalpha 0.8
    update_interval 1.0
    total_run_times 0
    own_window yes
    own_window_type override
    own_window_transparent yes
    own_window_colour hotpink
    own_window_hints undecorated,below,skip_taskbar,sticky,skip_pager
    minimum_size 176 360
    maximum_size 176 360
    maximum_width 176
    draw_shades no
    draw_outline no
    draw_borders no
    stippled_borders 0
    border_margin 0
    border_width 0
    default_color green
    default_shade_color green
    default_outline_color green
    alignment bottom_right
    gap_x 16
    gap_y 16
    no_buffers yes
    uppercase no
    TEXT
    $alignc${nodename}
    $alignc${sysname} ${kernel}
    $hr
    CPU:$alignr$cpu% ${cpubar 10,106}
    RAM:$alignr$memperc% ${membar 10,106}
    HDD:$alignr${fs_used_perc /}% ${fs_bar 10,106 /}
    BAT:$alignr${battery_percent}% ${battery_bar 10,106}
    $hr
    Download: Upload:
    eth0 ${downspeed eth0} $alignr${upspeed eth0}
    wlan0 ${downspeed wlan0} $alignr${upspeed wlan0}
    $hr
    ${alignc}ARCH NEWS
    ${rss http://www.archlinux.org/feeds/news/ 1 item_titles 10 }
    I know this looks confusing and probably is full of critical error, but that simple because I'm a conky noob. I basically just downloaded a profile I liked and completely changed it over the course of a few hours.
    Anyway, I'm rambling again, but if you've got any idea's, please do let me know.
    Best regards.
    Last edited by zacariaz (2012-08-27 17:19:35)

    Okay, so I've found sort of a solution to part of the problem, so what I have so far look like this:
    wget -quiet -O - archlinux.org/feeds/news/ | fmt -w 25 -g 25
    It works as long as there are no words longer than 25 character, which I should think is rare, even including package names and such.
    However there's still the issue parsing the xml so I get only what I want:
    <item><title>$content</title><link>
    This may be solved using some sort of terminal rss parser, but I would rather prefer not to.
    Then there's the issue with reloading.
    My current conky is set to reload every second, but of course one can't just pull the feed every second and I'm not convinced that conky has any built in solution for that problem. Of course I can always start a cronjob and save it all to a file, but portability would be nice.
    anyway, I'll return later.

  • Prob with fixed column widths and word wrapping in viewer

    i have a report where each record has a very long paragraph of text in it.
    In desktop and plus, the text column is at a fixed width and the text just wraps nicely according to the column width.
    But in Viewer, the column widths do not stay fixed, the text does not wrap, and the long text is displayed in a single line that completely stretches the column width off the page and requires a horizontal scroll bar.
    is there anyway to fix the column width in viewer, have the text naturally wrap, and prevent the column stretching. All word wrapping settings are on, but seem to have no effect. I can't seem to find any solution to this.
    Thanks...

    Hi Pritam,
    Per my understanding that you can't see the vertical scrollbar of the ReportViewer controls 2012 to scroll for the grid rows, but can see the vertical scrollbar of the web application, you also can't fix the headers while scrolling, right?
    I have tested on my local environment and can't reproduce your issue, but you have an alternative way to add some css  to the web form's source code to display the vertical scrollbar.
    Details information below for your reference:
    Please check below properties setting of the reportviewer which control the visibility of the scrollbar:
    AsyncRendering="true"
    SizeToReportContent="false"
    Please check if this problem also occur on other version of IE and other type of browser.
    Please check if you have done correct setting of the Fix data to freeze the table header as the step of below:
    http://technet.microsoft.com/en-us/library/bb934257(v=sql.100).aspx
    If step1 doesn't work, please click the source of webform.aspx and add below CSS to add the vertical scrollbar manually:
    #ReportViewer1 {
              overflow-y: scroll;
    Run the application you will see it display as below:
    Similar thread for your reference:
    https://social.msdn.microsoft.com/forums/sqlserver/en-US/f96b3b56-e920-411b-82ea-40467c922e66/reportviewer-control-vertical-scroll-bars
    If you still have any problem, please feel free to ask.
    Regards
    Vicky Liu

  • JTextPane always word wrapping

    I'm having problems convincing a JTextPane not to word wrap. My JTextPane is contained in a JScrollPane. I've looked and found out how to turn off word wrap in a JTextArea, and applied suggestions about turning horizontal scrollbars on, but it doesn't work. My JTextPane keeps wrapping text regardless of what I do to it. It seems to me that, since the JTextPane is more "sophisticated" than a JTextArea, I should be able to do this. Any suggestions?
    Matt

    Hi,
    overwrite the following method in your JTextPane-subclass
    public boolean getScrollableTracksViewportWidth() { return false;  }this works, if you use the scrollbar-policies below - I use that in a mud-client, returning false if I want it not to wrap and returning true, if I want it to wrap.
    I use the following on the JScrollPane, the JTextPane is in (assuming sp is your JScrollPane)
    sp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    sp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);Hope, this helps
    greetings Marsian

  • Word wrapping incorrect inside JTextPane on MAC 0.5/10.4 and Linux OS

    Hello java-dev team,
    In my application, I am using JTextPane as a text editor to create RTF text. The problem I observed with the JTextPane on MAC OS and Linux OS flavors (I tested on Ubuntu 8.04) is: whenever I am changing any of the text property (font color, font name, font style like bold, italic or underline) and then enter the characters without providing space, the whole word gets wrapped to the next line from the point where exactly the property change starts i.e. the new formatted text is jumped to the next line from the starting point of formatting.
    My requirement is, as I am not adding any space character while changing the property, the characters should be entered in the sequence and should come to new line as per normal word-wrap rule.
    Can anybody help me out in this regards with some solution as it’s a very urgent requirement?
    Below I am also providing the sample code to check the behavior. There is no dynamic facility to change the property in the below code but I am providing the text with multiple formatting settings through code itself. To reproduce the above issue, just type the characters using keyboard in between characters with changed text properties and you can see the whole word jumping to new line.
    import java.awt.Dimension;
    import javax.swing.JFrame;
    import javax.swing.JScrollPane;
    import javax.swing.JTextPane;
    import javax.swing.text.MutableAttributeSet;
    import javax.swing.text.SimpleAttributeSet;
    import javax.swing.text.StyleConstants;
    import javax.swing.text.StyledDocument;
    import javax.swing.text.StyledEditorKit;
    public class TestWrapping {
         JScrollPane scroll;
         JTextPane edit;
         public TestWrapping()  throws Exception {
              final JFrame frame=new JFrame();
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              edit=new JTextPane()
                   public void setSize(Dimension d)
                        if (d.width < getParent().getSize().width)
                             d.width = getParent().getSize().width;
                        super.setSize(d);
                   public boolean getScrollableTracksViewportWidth()
                        return false;
              edit.setPreferredSize(new Dimension(150,150));
              edit.setSize(150,150);
              edit.setEditorKit(new StyledEditorKit());
              scroll=new JScrollPane(edit);
              edit.getDocument().insertString(0,"11111111111111222222222222222222222222222222222222222",null);
              MutableAttributeSet attrs=new SimpleAttributeSet();
              StyleConstants.setBold(attrs,true);
              ((StyledDocument)edit.getDocument()).setCharacterAttributes(30,5,attrs,false);
              StyleConstants.setUnderline(attrs,true);
              ((StyledDocument)edit.getDocument()).setCharacterAttributes(35,5,attrs,false);
              StyleConstants.setFontSize(attrs,25);
              ((StyledDocument)edit.getDocument()).setCharacterAttributes(40,5,attrs,false);
              frame.getContentPane().add(scroll);
              frame.setBounds(0,0,150,150);
              frame.show();
         public static void main(String[] args) throws Exception {
              new TestWrapping();
    }The same functionality works fine on Windows XP and problem is observed on MAC OS 10.4/10.5, Ubuntu 8.04. I am using jdk1.5 on both the platforms. I tested using jdk 6.0 on Ubuntu 8.04, and the problem is easily reproducible. I placed a query in the respective OS forums also but did not receive any replies. I also searched the sun’s bug database, but could not find any bug addressing the mentioned problem correctly. I also logged issue at bugs.sun.com and was assigned internal review ID of 1480019 for this problem.
    If you need any additional information, please let me know.
    Thanks in advance.
    Regards,
    VPKVL

    VPKVL wrote:
    Hi All,
    Just want to update that when I checked this issue with JDK1.6 on Ubuntu 8.04, I am unable to reproduce the issue. Everything works as expected. But problem continues on MAC 10.5. So can anybody help me out in coming out of this issue on MAC 10.5.
    Thanks in advance.The only thing I can suggest is that you open a bug (radar) with apple ( developer.apple.com ), and then wait at least 12 months for Apple to get around to fixing it :s

  • Word Wrap Lost When Switching Between XML and Author Views

    I compose DITA topics in the XML view with the word wrap option selected. If I switch to the Author view to check something and then return to the XML view, my nicely formatted XML view with all the happy element-nesting tabs goes away. I wind up with an ugly chunk of flush-left code and text that's difficult to read. Is there a reason why FM can't remember the tabs and word wrap when I return to the XML view?
    I'm relatively new to using FM's structured side for DITA, so perhaps I'm missing the obvious solution to this problem. If you know the answer, I'd appreciate if you'd clue me in.
    Thanks!

    Sarah,
    When you switch from XML to Author (or WYSIWYG) view, FM does not "remember" the XML document at all. Instead, internally it creates a structured FM document with the same element structure (possibly modified by the underlying XML application). When you switch back to XML view, it creates a new XML document from the current element structure, thereby preserving any changes you made in Author View. FM is very conservative about writing white space to XML in order to avoid inserting unwanted significant space.
    If you do all your editing in XML View and want to inspect the formatted version of the document without making changes to white space, always make a copy of the XML document (with File > Save As) and use the copy in Author View.
    --Lynne

  • Help with a tabel word wrap

    Hi
    Any one help me please below is the html I have. its reading
    a .js file from an external source. The problem is word wrapping
    the content I need to make the conten wrap with in this table as i
    have no control of how the external content is constructed.
    Any help please.
    <table width="100%" border="0" cellpadding="0"
    cellspacing="0" id="PARA2">
    <tr>
    <td><script language="JavaScript"
    type="text/javascript" src="
    http://www.domain.net/p2.js"></script></td>
    </tr>
    </table>

    anyone not help with this please

  • Word Wrap very annoying?

    I just switched over to Dreamweaver because of the built in ftp server functionality.  So far, I have found it to be a very nice editor. 
    One problem I have it with wordwarp in the coding.
    If a line is wrapped, why does it not indent to the same column that the line started on. 
    For example if I was inside several elements and this particular <p> started in column 20, if the line runs over, it wraps and the next line starts on column 1.  This makes the code very hard to read as you have out of place text.
    <body>   
         <div>
              <p>This is just a long sentence with a bunch of rambling so the line will wrap back
    around to the first column so you can see what I am talking about.
         <div>
    </body>
    It would be so much better if it looked like this:
    <body>
         <div>
              <p>This is just a long sentence with a bunch of rambling so the line will wrap back
              around to the first column so you can see what I am talking about.
         <div>
    </body>
    Is there way to do this?
    I have searched the adobe forums and google, but I feel like I am just searching for the wrong thing because all I ever come up with at the most is how to turn word wrapping on or off.

    You can turn on that style of word wrapping, but it's not enabled by default because it relies on inserting a hard newline character each time a line is wrapped. Newline characters are treated by JavaScript as indicating the end of a statement, so this style of wrapping can break JavaScript on your page if you're not careful.
    To enable hard wrapping with text indentation, open Preferences (Edit menu on Windows, Dreamweaver menu on a Mac), and select the Code Format category. Select the Automatic wrapping checkbox and set the column (character) at which you want the line to be wrapped.
    The Dreamweaver default is to use soft wrapping, which is controlled by View > Code View Options > Word Wrap. This option toggles soft wrapping on and off. A soft wrap automatically wraps code when it reaches the right edge of Code view, but without inserting a newline character.

Maybe you are looking for