JTextArea setWrapStyleWord(true) does not work if appending text - jtextarea

According to Oracle at JTextArea documentation, if you wish to wrap lines AND wrap at word boundaries and not character boundaries you must use code as follows:
jtaOutputPrimes.setLineWrap(true);
jtaOutputPrimes.setWrapStyleWord(true);
Please note that the jtaOutputPrimes is the name of my JTextArea on my JPanel.
The issue comes in when I use the method append to add text to the JTextArea as follows:
jtaOutputPrimes.append(",");
In this case, the setWrapStyleWord setting does not work. It continues to use the character boundaries and not the word boundaries.
I have found another person experiencing same issue here: setWrapStyleWord issue
Now, lets say you are running an JApplet that has this JTextArea. If you type in the text area, it will word wrap fine, but any passed text from the append method does not work.
I believe this is a bug, and I cannot find Oracle acknowledge it as such anywhere.
Can anyone help? Thanks!

I found out why this was happening, and this simple fix may be beneficial to others. The issue came into play because when I appended the comma (,) to the JTextArea it was eliminating the white space between words. To fix this, I simply placed a space after the comma like so, and it worked.
jtaOutputPrimes.append(", ");

Related

Underlining text posted to slack

I am trying to see if there is a way to underline a text posted to slack. I am using webhook for posting messages to slack.
You can approximate it with Unicode’s COMBINING LOW LINE character: http://www.fileformat.info/info/unicode/char/0332/index.htm . Before posting, split your string along grapheme boundaries and insert a COMBINING LOW LINE after each. This sort of works, but with Slack’s default font the underline sometimes splits visually between characters. It’s enough though to give an impression, which might be what you want if, for example, you’re trying to give an example of the position of a link within a piece of text.
I don't think this can be done. See https://api.slack.com/docs/formatting for the available message formatting options.

Why does Android Studio indent with two tabs?

I'm wondering whats the point of this, first I think it's not a good idea to use space for indentation (somehow Android Studio think it does), second even if I tell it to use tabs it always starts with two tabs on new line, instead of one, turning this:
getSupportFragmentManager().beginTransaction().commit();
into this:
getSupportFragmentManager()
.beginTransaction()
.commit();
Why the two tabs? I know you can set it as "Continuation Indent" to one tab or whatever you want, but cant really understand this, is there anyone who uses two tabs instead of one? What is the thought behind it? Why two tabs by default?
I can only assume it's so that the continuation method calls are somewhat closer to the first method in the chain, for readability. Variable/field/method names are generally more than 8 characters long; they are rarely around 4 characters. When writing using a builder pattern, you generally put the first method on the first line and then subsequent methods should be roughly underneath.
E.g. this:
foobarbaz.builder()
.foo()
.bar()
.baz()
.build();
Rather than this:
foobarbaz.builder()
.foo()
.bar()
.baz()
.build();
In this case, it's more obvious that the methods are stacked on top of each other in the first case.
Obviously the readability depends on the length of the method/variable name on the first line. But I think JetBrains just tried to guess the typical length and set the continuation indent accordingly.

Mediawiki/wikipedia text format issue

so i got an issue with text formatting and i have no idea how this problem is called or what i should search after, so i thought i try to explain it here.
It's literally nothing dramatic or should take long, i simply want to write stuff like
''italic'' or '''bold'''
without that it actually gets italic or bold... i literally want
''italic''
to be displayed. I've also tried to use code blocks but even within the blocks it writes italic then.. i'm sure there is a <..> command but i simply can not find it
Does anyone know?
try this:
<nowiki>''italic''</nowiki>

Show multiline text in grails page

I'm going mad with this, I need to show a text I got from a textarea in grails 2.3.7 but when I replace \r\n characters for br/ and do an encodeAsHTML() I get the br's every where instead of new lines.
How is it done? this is what I've tried:
${cotizacionInstance.descripcion.encodeAsHTML().replaceAll('\r\n', '<br/>')}
${cotizacionInstance.descripcion.replaceAll('\r\n', '<br/>').encodeAsHTML()}
<%=cotizacionInstance.descripcion.replaceAll('\r\n', '<br/>').encodeAsHTML()%>
<%=cotizacionInstance.descripcion.encodeAsHTML().replaceAll('\r\n', '<br/>')%>
<%=cotizacionInstance.descripcion.replaceAll('\r\n', '<br/>').decodeHTML()%>
<%=cotizacionInstance.descripcion.decodeHTML().replaceAll('\r\n', '<br/>')%>
I don't like the way it comes out if I use the pre tag, because I loose all responsiveness.
I see that in the google chrome inspector I get my string between double quotes but I don't know how to remove those.
Thanks
There are factors left out of your description which make it impossible to say for sure but one way to get the behavior you are after is to mark the text as raw with something like this...
${raw(cotizacionInstance.descripcion.replaceAll('\r\n', '<br/>'))}
I hope that helps.
You need to esacpe your backslashes:
replaceAll("\\n", "<br/>")

Using LocationTextExtractionStrategy in itextSharp for text coordinate

My goal is to retrieve data from PDF which may be in table structure to an excel file.
using LocationTextExtractionStrategy with iTextSharp we can get the string data in plain text with page content in left to right manner.
How can I move forward such that during
PdfTextExtractor.GetTextFromPage(reader, i, new LocationTextExtractionStrategy())
I could make the text retain its coordinate in the resulting string.
As for instance if the first line in the pdf has text aligned to right, then the resulting string must be containing trailing space or spaces keeping the content right aligned.
Please give some suggestions, how I may proceed to achieve the same.
Its very important to understand that PDFs have no support for tables. Anything that looks like a table is really just a bunch of text placed at specific locations over a background of lines. This is very important and you need to keep this in mind as you work on this.
That said, you need to subclass TextExtractionStrategy and pass that into GetTextFromPage(). See this post for a simple example of that. Then see this post for a more complex example of subclassing. The latter isn't completely relevant to your goal but it does show some more complex things that you can do.

Resources