jtextcomponent

Changing the font of text being typed in a JTextArea

I am working on a chat application and I want the user to be able to change their font while typing messages. I tried using the setFont() method but it changes the font for the entire text within the JTextArea component and when the text is sent to the display area, another JTextArea component, the font changes do not appear. Instead i...

Getting the removed text from a Java text component

A JTextComponent allows you to add a DocumentListener to its Document, which will tell you when text was added or removed, and the offset and length of the change. It will not, however, tell you what the text of the change was. This is not much of a problem for text addition, as you can use the offset and the length to find the added t...

Dragging text from a Word document to a Java text component?

When you drag a block of text from a Word document into a Java text component, the text is removed from the Word document. This is obviously undesirable in some cases. Is there a way I can prevent Word from removing the text, while still copying it into the Java text component? ...

How to get the added, removed or changed chars from DocumentListener?

Hi, I have JTextAreas and need to get chars, which are added, removed or changed to it. How do I do this? ...

What is the easiest way to output only a certain number of digits after a decimal place in a JTextComponent (Java swing)?

I am using both JLabels and JTextFields, and need to be able to truncate my doubles to two decimal places when they are outputted to the application. What is the easiest way of doing this (preferably without switching to JFormattedTextFields)? Thanks, badPanda :D ...

Getting an action after text is pasted into a JTextComponent (Java)

This really puzzles me. I have a JTextComponent for which I've added a right-click cut\copy\paste menu using a JPopupMenu and DefaultEditorKit.Cut\Copy\PasteAction(). JMenuItem cutItem = new JMenuItem(new DefaultEditorKit.CutAction()); JMenuItem copyItem = new JMenuItem(new DefaultEditorKit.CopyAction()); JMenuItem pasteItem = new JM...