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
1
vote
1 answer

Multiple fonts and styles in JTextComponent

I am looking for a way to print content in JTextComponent's text with multiple fonts and styles. For example: first Title with bigger font and then some custom text in different style in one component
Indigo_heart
  • 129
  • 11
1
vote
0 answers

JTextArea - are 2 different highlight colors possible?

I want to highlight the text in a JTextComponent with two different colors. Is this possible with JTextArea (and if yes how?) - or do I need to use JTextPane or JEditorPane (if latter: which one is to recommend if the only thing I really want to…
1
vote
1 answer

JTextComponent inside JPanel inside JScrollPane

I recently have had the need to put several Components, a JTextPane among them, inside of a single JScrollPane's viewport view. (See details here, if interested). I put all the Components (two JPanels and the JTextPane) inside of another JPanel,…
Blacklands
  • 65
  • 1
  • 2
  • 6
1
vote
2 answers

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…
Viktor Sehr
  • 12,825
  • 5
  • 58
  • 90
1
vote
2 answers

Press TAB to next Java in Vertical axis component

I have a panel null layout and have the following code int k=130; int h=10; for (int i=0; i<22; ++i) { jTextFieldArray[i] = new JTextField(); jTextFieldArray[i].setBounds(k, h, 120, 25); String s = Integer.toString(i+1); …
Wesam
  • 23
  • 3
1
vote
0 answers

method gettext(); dont get all he newlines when the caretUpdate Event

hi i'm trying to make a method to get the exact position of the caret in a JTextComponent similar as the getMagicCaretPosition(), but when I type only newline the method gettext(); doesn't get all the newlines that I have in my component when i used…
WearFox
  • 293
  • 2
  • 19
1
vote
2 answers

How can I output only a certain number of digits after a decimal place in a JTextComponent?

I am using both JLabels and JTextFields, and need to be able to truncate my doubles to two decimal places when they are displayed by the application. How can I perform this truncation, preferably without switching to JFormattedTextFields?
badpanda
  • 2,446
  • 5
  • 34
  • 45
1
vote
2 answers

JTextPane select() not working if JTextFeild is in JFrame

I am trying to select some text programmatically in a JTextPane but it isn't working. I found out the problem but I don't know how to fix it. It works fine if there is no JTextFeild in the JFrame but if I add it, the focus goes to the JTextFeild and…
usama8800
  • 893
  • 3
  • 10
  • 20
1
vote
1 answer

Off-Screen JTextComponent

I am making a paint program and I'm coming across some trouble figuring out how to make a text tool. What I want to do is click and drag to make a textbox appear on the canvas. The problem is that I don't want this to just be a JTextComponent…
pigi5
  • 74
  • 1
  • 10
1
vote
0 answers

Key bindings up arrow is not recognized for the first time

I have used keybindings for up arrow action, However it doesn't seem to work for the first time and it works from second press as i implemented, Below is my code, txtLog = new JTextArea(); Action upArrowAction = new UpArrowAction(); …
user3164187
  • 1,382
  • 3
  • 19
  • 50
1
vote
1 answer

How to trigger keyReleased event in java swing

i am trying to trigger key released event in java swing. txtEmailId.addKeyListener(new KeyAdapter() { // override keyReleased listener on the Email TextField @Override public void keyReleased(KeyEvent e) { …
Uday A. Navapara
  • 1,237
  • 5
  • 20
  • 40
1
vote
1 answer

Add formatted text

im stuck on a simple question, i want to display formatted text in a swing control and keep on adding new values into it, i don't want to use .setText(.getText + text) for personal reasons, (something like the append method for text area is what I…
1
vote
3 answers

Adding a context menu to all Swing text components in application

Swing text components don't have a context menu with cut/copy/paste/etc. I want to add one so it behaves more fluently and like a native app. I've written a menu for this and it works fine. I add it to each text box…
Boann
  • 48,794
  • 16
  • 117
  • 146
1
vote
1 answer

In Java Swing, can I receive Caret events in real time?

I'm writing a hex editor-like view, which is composed of two JTextComponents (hex and ASCII). I'd like to synchronize the selection between the two views, so I've implemented a CaretListener for the two components. This works well for responding to…
Willi Ballenthin
  • 6,444
  • 6
  • 38
  • 52
1
vote
0 answers

Arabic Typesetting font slowers my JTextArea, JTextPane and JTextEditor

I am using JTextArea to show heavy text in Urdu, Arabic and English language in Java. The problem is that my GUI freezes for 12-15sec when I use Arabic Typesetting font for JTextArea. I am getting text from XML and then showing in textarea, also…
Shahrzad
  • 1,062
  • 8
  • 26