I have an application which continuously receives data on a socket, and then logs this data to a file while also displaying this data in a JTextPane. Naturally, as data is written to the underlying document of the JTextPane the memory usage continues to increase.
Is there a simple way of limiting the memory which the JTextPane is allowe...
I am developing a simple WYSIWYG RTF editor in Java and have a small issue. I need to be able to synchronize the style selection toggle buttons (such as bold, italic, underlined) to the users text selection. For example, if the current text selection is plain, the bold, italic and underlined toggle buttons are not selected, but when the ...
I have an HTML file that I am loading into a JTextPane which contains two DIVs I am trying to show side-by-side (using CSS float). Whatever I try, though, does not work. The instructions element is displayed below the title element, always. I've tried adjusting the widths as well. Does JTextPane not support this CSS property - must I use...
I am trying to create a very simple chat window that simply has the ability to display some text, which I add to from time to time. However I get the following run time error when attempting to append text to the window:
java.lang.ClassCastException: javax.swing.JViewport cannot be cast to javax.swing.JTextPane
at ChatBox.getTextPa...
How do I set a background image to a JTextPane - some sort of a watermark.
I tried this option - creating a child class of JTextPane and use the paint method to draw the image.
But then the text is displayed "below" the image than above.
Is there any "standard" or "well known" way to do this?
(BTW, I tried (something silly?) making t...
I can't squeeze together the lines in a Java JTextPane if I set the content-type to text/html. I would like them as close together as they are when the content-type is text/plain, the default.
The line-height, top-margin, ... CSS properties don't seem to help :(.
This is the output of my sample program, that shows that the lines do tak...
Hi All,
I've got a panel displaying a JTextPane backed by a StyledDocument. When I print a string of text in, say Arial 16, the text it prints is the same size as the Arial 16 Word prints. However, the Arial 16 in the JTextPane appears to be smaller than the Arial 16 Word displays. Is there some sort of flaw in the translation of Swi...
i was trying to do some simple text formatting using JEditorPane but then as knowledge grew i found JTextPane easier to implement and more robust.
my query is how do i save the formatted text in JTextPane to file? it should be RTF or HTML or other.. as this file is not opened by the application again.
it is a chat history text file wit...
i have the following code trying to save the contents of a JTextPane as RTF. although a file is created in the following code but it is empty!
any tips regarding what am i doing wrong? (as usual dont forget im a beginner!)
if (option == JFileChooser.APPROVE_OPTION) {
///////////////////////////////////...
Is it possible to display a base64 encrypted image into a JTextPane ?
Here my code
JTextPane jTextPane = new JTextPane();
javax.swing.text.html.HTMLEditorKit eKit = new javax.swing.text.html.HTMLEditorKit();
jTextPane.setEditorKit(eKit);
jTextPane.setContentType("text/html");
// my base64 image, used then in the img tag in the html...
The following class implements a chatGUI. When it runs okay the screen looks like this:
The problem is very often when i enter text of large length ie. 50 - 100 chars the gui goes crazy. the chat history box shrinks as shown in this
.
Any ideas regarding what is causing this?
Thank you.
PS: the attached class below is complete co...
Hi all.
Problem:
I have CaretListener and DocumentListener listening on a JTextPane.
I need an algorithm that is able to tell which line is the caret at in a JTextPane, here's an illustrative example:
Result: 3rd line
Result: 2nd line
Result: 4th line
and if the algorithm can tell which line the caret is in the JTextPane, it ...
Hi all.
Problem:
I have the following JList which I add to the textPane, and show it upon the caret moving. However, after double clicking on the Jlist element, the text gets inserted, but the caret is not appearing on the JTextPane.
This is the following code:
listForSuggestion = new JList(str.toArray());
listForSuggestion....
I'm displaying some tables as HTML code (rendered by a Freemarker template) with a JTextPane. I also have some HTML links in this HTML output which can be used to interact with the values of the table (For example "Delete a row" and stuff like this). Currently I always recreate the whole HTML output on each change and replace the whole d...
I currently have a JTextPane that will be displaying text coming in from different streams. The way that the user can tell which stream the text came from is that the text from each stream has a different Style to it. Is there a way to make a Style that will hide the text so that I can filter out different pieces of text?
Thank you.
...
I'm trying and failing to understand how to use Java's text editor components to colorize text as you insert it. I don't want or need a fully featured syntax highlighting library.
Basically, I have a JTextField (or some other JText... component), and a list of words. I want any words in the field that appear in the list to be red, and t...
Is there a way to create horizontally centered text for a JTextArea like with a JTextField?
setHorizontalAlignment(JTextField.CENTER);
Is there a way I can accomplish the same thing with a multi-line text area? I can't find a method for it with JTextArea, so is there another option? JTextPane? If so, how?
...
I want to show the caret on the jTextPane when i extends it to jPanel instead or JFrame. My problem now is when I extends my class to jPane the caret wont show on the jTextPane.
...
My application's main JFrame contains a JTextPane. While it has focus, it consumes all keyboard shortcuts ("accelerators") instead of passing them on to the JFrame's JMenu. This means that while it has focus, eg ctrl-n for "New Document" doesn't work.
Obviously it's useful that it handles ctrl-A/C/V/X correctly for select all/copy/paste...
I'm using a JTextPane to display some HTML that contains a table with a border. I want it to have a simple 1 pixel border.
I tried using style="border: 1px solid; border-collapse:collapse". This works in a web browser, but not in JTextPane.
Is there any way to have a simple 1 pixel table border using HTML in a JTextPane?
...