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).
Questions tagged [jtextcomponent]
149 questions
1
vote
1 answer
Block text-writing after n characters
I have this code, that "disables" user input on a JTextField after n characters are inserted:
JTextField tf = new JTextField();
tf.addKeyListener(new KeyAdapter() {
public void keyTyped(KeyEvent e) {
if (((JTextField)…

BackSlash
- 21,927
- 22
- 96
- 136
1
vote
1 answer
Best way to remap input of certain characters/keys to a JTextComponent?
I am working on a JTextPane that works (almost) exactly like the tags input field here on stackoverflow. For that I am converting text to components as soon as a user hits enter, tab or space. Naturally I do not want any of those characters to…

AplusKminus
- 1,542
- 1
- 19
- 32
1
vote
1 answer
How do I receive input from a textbox in a JFrame?
The following method extends a JFrame, but I need a swing textbox inside it to receive double values and store them in a variable. the textbox must be added to the container.
public class myClass extends JFrame{
Container container;
…

rainhider
- 49
- 1
- 4
- 13
1
vote
2 answers
JTextField with both ActionListener and DocumentListener
I have a couple of JTextFields on a very simple JFrame. Field 1 gets the focus first. When the user enters a number and hits enter, I want the focus to switch to Field 2. To accomplish that, I have an ActionListener attached to Field 1. I also have…

AndroidDev
- 20,466
- 42
- 148
- 239
1
vote
0 answers
javax.swing.text.View.createFragment strange behaviour in java7
I have encountered strange behaviour of aforementioned method.
There is a legacy component that is used to display xml file contents, it works in java6, however when I switch to 1.7_10 it fails as end offset is out of view's bounds.
I have…

michael nesterenko
- 14,222
- 25
- 114
- 182
1
vote
3 answers
Show the HTML code preview in JFrame?
I am writing a Java code which also consists of HTML. I want to preview that HTML code in JFrame only. Is there any solution available within the Java API?
Could you please guide me to solve this problem?

mani
- 1,012
- 7
- 26
- 47
1
vote
1 answer
Pagination of text in GUI
I write book reader using Java Swing. Is it possible to paginate some text in a panel? In what way I can do pagination?

Marat Kadyrkanuli
- 11
- 1
0
votes
1 answer
Text rotation in Java2D
I am making a program in Java that should show rotated text.
However, I am having problem visualizing the text correctly.
A small test program I made is given in the next listing.
This test program should rotate a line of text (and a rectangle…

zvezda_n
- 75
- 9
0
votes
2 answers
Unable to delete searched value
The class below is my delete class, i want to delete the users from the database, i have a Add class and Search class, their share the same database private Database db;.
package TakeMeOut;
import java.awt.BorderLayout;
import…

Mohammed Ali
- 3
- 3
0
votes
2 answers
Expandable JTextArea
Part of the application I am building demands that I display a variable amount of text in a non-editable component of some sort. Currently this has been implemented in JTextArea, but JTextArea has only the setRows() to set the vertical size of the…

Steve Cohen
- 4,679
- 9
- 51
- 89
0
votes
1 answer
JLabel word wrapping of string with no spaces
I am using html to make text in a JLabel span multiple lines. However if I enter a long string with no spaces it doesn't go onto a new line and instead causes an underlying JScrollpane to display a horizontal scrollbar and pushs the components to…

csss
- 1,937
- 2
- 14
- 24
0
votes
1 answer
Selectable JLabel, without just a JTextfield
I need to be able to select the text in a JLabel. Ive read some guides on the net that talk about using a JTextfield to simulate a JLabel, however this is no use to me as I my JLabel will span multiple lines. So any ideas on how to do this or if…

Jim_CS
- 4,082
- 13
- 44
- 80
0
votes
2 answers
How can I print a RTF formatted String to a JLabel?
I have my custom JComponent which do a lot of drawing operations.
They also include drawStrings for text paragraphs, but now Id like to format the text (in a seperate window with jtextpane or another RTF editor) (bold, font-size, align, font-color,…
0
votes
2 answers
Display and append Icons on JEditorPane/JTextArea with every icon displayed in newline?
I m trying to display System icons for file extention of JEditorpane i m able to display but only last icon get displayed ?I want to append and display each icon on newline?
String fileList[] = {".pdf", ".txt", ".doc", ".exe"}
JLabel…

Dorjay
- 85
- 1
- 5
0
votes
1 answer
How to disable custom Shortkeys only when user is typing in some component and enable it again when focus is not on editable component in java?
I am using following code to set shortcut keys for my JFrame.
KeyboardFocusManager keyManager;
keyManager=KeyboardFocusManager.getCurrentKeyboardFocusManager();
keyManager.addKeyEventDispatcher(new KeyEventDispatcher() {
@Override
public…
user11888240