Actually i am trying to display the line number and coloumn number the user is currently typing in a JTextArea . My question is how can i convert CaretEvent.getDot() to rectangular coordinates so that i can achieve this ? Or is there any other method ?
Perhaps you're looking to use the JTextArea method, public Rectangle modelToView(int location). Actually this is a method from JTextArea's parent class, JTextComponent, and can help translate an int location in the document to the current rectangle location in the GUI itself, relative to the text component.
i am trying to display the line number and coloumn number the user is currently typing in a JTextArea
Check out Text Utilities. It provides methods like:
getColumnAtCaret(...)
getLineAtCaret(...)
Related
I need to create a comment box using PDFBox. I won't be aware of the coordinates of the text. How do I create a division of color surrounding the text without knowing the coordinates?
I have found how to create a division of color by using the coordinates using AddRect function. I need to do it without knowing the coordinates.
Expected output:
I want the output to look like the comment boxes present in the output of this image I have attached
I want to center a block of text in a rectangle. I am currently using the PDFont.getStringWidth method for centering horizontally. However, I do not see a corresponding PDFont.getStringHeight method. Is there a way to get the height of a string, taking into account descenders? I see the getHeight method, but that would only work for a single character, and sounds like it would be expensive to call for a long string.
I'm usint this class that provide to draw a cicle with inside a title and subtitle. the code is this (i'm not the author): https://github.com/ylyc/circular_progress_bar/blob/master/src/com/lylc/widget/circularprogressbar/example/CircularProgressBar.java . All works fine but when the subtitle text is more large it outside of the parent.. how can i scale this programmatically according to the screen resolutions? Thanks.
check this out
http://docs.oracle.com/javase/1.5.0/docs/api/
it has all of the methods in java in it. just look up the class of the object for the text and see if there is one.
I want to do some custom drawing of brackets around certain text in a text control in Java Swing. But I need to know where to draw them. I do know the exact range of characters in the text content, so I just need to be able to translate those indexes into specific locations on the control so I can draw.
Is there some way to do that?
I plan on making a multi comparison program. It will compare multiple files by displaying N number of files in a grid where N = X * Y. X and Y are the width and height of the grid elements. Easy enough, I know how to do this pretty much.
The question:
How do and in what way is best to highlight individual characters in each of these grid elements? I plan on highlighting matching text that is found in the same position.
I'd use a JTextPane rather than a JTextArea, and read up on the StyledDocument class. This will give you all sorts of options.
You could use a JTextArea with a Highlighter. See the second example on this page for how.
I'm not sure what you mean by "Highlight the characters", but to bring attention to grid elements, or pairs of grid elements, you could set the background color of the appropriate component.