Questions tagged [jtextcomponent]

JTextComponent is the base class for swing text components. It tries to be compatible with the java.awt.TextComponent class where it can reasonably do so. Also provided are other services for additional flexibility (beyond the pluggable UI and bean support).

149 questions
2
votes
1 answer

move up down button in the text areas

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 ?
zenx
  • 291
  • 1
  • 2
  • 9
2
votes
2 answers

Clear Swing Component values

Is there are a method to clear the value of a Swing component. For example if we take the JTextField every time I want it to be cleared I have to call - txtField.setText(""). I once made a utility method for these type of cases - public static void…
Chan
  • 2,601
  • 6
  • 28
  • 45
2
votes
2 answers

message console Java

I have the code to this open source Message Console in java, but it simply won't compile. Can anyone see if it is operational using their IDE? import java.io.*; import java.awt.*; import javax.swing.*; import javax.swing.event.*; import…
user1299661
  • 183
  • 2
  • 3
  • 11
2
votes
1 answer

Accessing files under .jar in a swing application?

Referring to my previous question, I want to ask that how can I read a file in different folder into the similar .jar. The folder hierarchy and details are provided with that question. My main problem is with a line of code: JTextPane textPane =…
Asif
  • 4,980
  • 8
  • 38
  • 53
1
vote
1 answer

How can I insert multiple tooltips at different caret positions in a JTextcomponent?

I'm currently working on a project that requires the user to annotate (or comment) text inside a text component. The user would double click somewhere in the text and a tooltip would appear at that position (With text that they specify in another…
David Kaminsky
  • 89
  • 2
  • 12
1
vote
1 answer

Underline StyleConstant in a different colour with AttributeSet

I am implementing a spellchecker and wondered if there is an easy/obvious way of underlining some text in a different colour such as Red. I have everything set up and underlining with the following code (also sets the color of the text): private…
maloney
  • 1,633
  • 3
  • 26
  • 49
1
vote
5 answers

Disable double click selection in a JTextComponent

Generally when you double click in a text component, the entire word is selected. I would like to disable selection of this single word but still maintain the ability to click and drag to select it. Example: "The quick brown fox jumps over the lazy…
David Kaminsky
  • 89
  • 2
  • 12
1
vote
0 answers

JComponents does not show up on the screen with enabled double buffering

I am writing a 2D game with Swing. For the menu I use JButtons and now I want to use a JPasswordField. The problem is: If I try to write something in it, the programme crashes. I located the error to this single line of…
1
vote
4 answers

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…
Amanda S
  • 3,266
  • 4
  • 33
  • 45
1
vote
3 answers

java.lang.ClassCastException: javax.mail.internet.MimeMultipart cannot be cast to java.lang.String at NewClass.main(NewClass.java:34)

This is the code that is intended to fetch up the email from Gmail server. Along with it also brings the subject and the sender separately. The inbox that i am checking has 5 messages.(some read and some unread) I wanted the html content to be…
Suhail Gupta
  • 22,386
  • 64
  • 200
  • 328
1
vote
1 answer

Syntax Highlighting

I created a Summer project for myself and decided that I wanted to write a simple text/code editor. I think everything has been going well so far. I created a basic GUI and can do simple operations like Open, Save, and Create files. Right now I am…
Hunter McMillen
  • 59,865
  • 24
  • 119
  • 170
1
vote
1 answer

Highlighting changing text in a java swing jtextcomponent

I am trying to highlight some code in a JEditorPane like this: import javax.swing.JEditorPane; import javax.swing.JFrame; import javax.swing.text.DefaultHighlighter; import javax.swing.text.Highlighter; public class Driver { public static void…
Mark M
  • 1,807
  • 2
  • 21
  • 40
1
vote
1 answer

Getting the current offset in the HTMLDocument of a JTextComponent

In a Swing application I'm using a JTextPane with an HTMLDocument backend. At one point I'm inserting some sort of placeholders programmatically into the document with document.insertString(...) For some reason, using the…
chris
  • 280
  • 1
  • 9
1
vote
2 answers

How to re-position cursor in TextArea

i have set some text in JTextArea. The cursor is in 5th line. Now I want to set some text in the first line. So is it possible to re position the cursor to desired line?
Anukool
  • 732
  • 1
  • 9
  • 21
1
vote
1 answer

How to change print params when using new java 1.6 JTextComponent print()

I have a JTextComponent (JTextArea). I am trying to print its contents with using the new 1.6 .print() functionality. This is working well. I am also doing this in a headless/non-interactive mode using the following method signature: boolean…
a1o1
  • 68
  • 1
  • 5