move up down button in the text areas - java

I have two text areas on the screen, I have made bold the different words between two text areas and I want to have a button for up and down to go the different words on the text areas. Is this possible ?

have to look at JTextArea, but notice isn't designated for nice formatting or higlighting, then to use JTextPane instead
TextUtilities can help you to find out desired indexes rellative to screen or rellative to the model (Document)

Related

different "words" in two text files and make bold them, show on the screen in two txt. files

I have compared two text files and found different words each other. And I want to show the different words in two text files and make them bold, show on the screen.
This is my code for comparing but I didnt do that how can i show the different words in these txt. files visually.
When you have a word list, you need to create two JTextPanes, put the text documents in them and highlight the differences.
Code examples: JTextPane Highlight Example and Inserting Styled Text in a JTextPane Component

Different text color in a JTextArea

Is it possible to have different rows in different colors in a textarea? Have you an example for that?
Not with a JTextArea. You can, however, use a JTextPane which allows for attributes to be applied to text. If you want examples, take a look at the Text Component Tutorial.

How to give different - 2 color to text written in JTextArea?

I want to change color of text written in JTextArea. For e.g. I am pasting Java code in JTextArea.
I want to give the different-2 color to Java keywords, variables and classes written in code.
Is it possible?
See Rob Camick's Message Console. It seems perfect for this use case.
Actually '2 color' might not be enough for this.
See How to Use Editor Panes and Text Panes for more details on the formatted text components that might replace JTextArea.
it's not possible
if you want to set different colors in the same area, i think JTextPane could help you
i'm not sure how to use that, but i found this
http://docs.oracle.com/javase/tutorial/uiswing/components/editorpane.html

Turn fonts to Monospaced

I am trying to make a bizarre text editor for people with reading problems with Netbeans. You load the text you like and the editor starts highlighting it word by word with bold letters. The change from plain to bold constantly change the word dimensions and moves the line. One solution was the Monospaced Font but I would like to add a few more fonts available for the user to choose. Is there any way to do this with Arial for example by giving some orders to the JTextPane?
You can manually split the String with <br/> by counting characters and splitting at the right spot to keep the width under your desired character width. Give some leeway so if you get a big word, it won't still go to the next line.
Alternatively, you could use a JList to display your lines (instead of using <br/>). That way, there's no way the line would split to the next line. However, if you do it that way, the user will click on the list like a list and not be able to select text like in a normal text pane.

Java JTextArea Question

I am designing an on-screen form to be filled in, and I think it makes sense to stick it together as a collection of text areas. I note in the documentation of JTextArea that a text area can be subdivided into rows and columns, but I can't find any methods that appear to deal with placing text directly in any specific row/column cell in a text area.
Are there such methods, or is there an alternative text component that would work better for this purpose?
Thanks in advance for any insights.
John Doner
If you want a table, there is JTable but it is a bit more complicated. (Here is a tutorial) Alternatively you could put your JTextAreas into a layout such as GridLayout
A bit hackish, but you could insert (row-1) newlines and (column-1) space characters before your actual content. Of course that would only work on a previously empty text area.
However, you can extend that approach so that you only insert characters if needed, and otherwise just count already existing characters. That is, to go to a row, you skip the first row-1 newlines. Then in that line, you skip the first column-1 characters.
If there aren't enough newlines or characters already in the text area, you add more at the end of the text.
However, it gets trickier if your text content contains newlines itself.
It's doable, but it's gonna be ugly.
The row and columns values are just used to give the text area a preferred size.
I don't see the point of trying to set text at a specific row when creating a form. Generally forms would be designed with label/text field pairs, so the user know where there are entering the text.
If you text area is for output then you just add new lines when you want to display text on a different line.
Forcing a text area to be able to insert text at a given row/column is definitely not the way it was intended to be used.
I don't understand the real requirement so I can't make any other suggestions.

Categories

Resources