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
0
votes
2 answers
implementing a copy/paste action in java
Im having some issues getting the copy and paste methods from JTextComponent working
for my program i have an array of strings that will be the menu choices. "Copy" and "Paste" are two of these.
else if…

HologramWolf
- 3
- 2
0
votes
0 answers
Position.Bias always showing Forward in NavigationFilter
Consider my simple navigation filter,
class Main
{
JFrame frame=new JFrame();
frame.setSize(400,400);
frame.setLayout(new FlowLayout());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
JTextArea jt=new…

JavaTechnical
- 8,846
- 8
- 61
- 97
0
votes
3 answers
Applet: visually bugs out only in browser, and throws exception from Swing
We've been struggling here at the office with a seemingly unsolvable bug in one of our (massive) applets, this one being a Java simulation of MS Word, for exam purposes. The exception seems to stem from swing itself, and I'm not sure how I would go…

Mammon_ZA
- 1
- 2
0
votes
2 answers
Swing Component with automatic line wraping and limited width with HTML support
I want to implement a small tooltip with a scrollbar like the one in eclipse that appears when hovering above a class or member.
The problem I have is finding a way to limit only the width but not the height of a component within the scroll pane I…

salbeira
- 2,375
- 5
- 26
- 40
0
votes
2 answers
How to set DocumentFilter with input length and range? e.g. 1-3 or 10-80
I'm using DocumentFilter to restrict input as integer or decimal.
And the code I post here is working well for that.
Can anybody help me about how to restrict the input length or range in the given code?
Thanks!!
class MyIntFilter extends…

Jiayi Guo
- 105
- 3
- 14
0
votes
1 answer
Java Swing: Using a Document Listener to Handle the Return Key
I have a document listener that works just fine. However, I'd like to add some functionality to it so that when the user hits the Enter key, the focus shifts to another object. I can't figure out how to trap this. Here is my…

AndroidDev
- 20,466
- 42
- 148
- 239
0
votes
4 answers
Reading a txt file in a Java GUI
All I want to do is display the entire contents of a txt file. How would I go about doing this? I'm assuming that I will set the text of a JLabel to be a string that contains the entire file, but how do I get the entire file into a string? Also,…
user1212818
0
votes
1 answer
Writing multiline JTextArea content into file
I have to write the content of textarea into a file with line breaks. I got the output like, it is written as one string in the file.
public void actionPerformed(ActionEvent ev) {
text.setVisible(true);
String str=…

Rachit
- 11
- 3
0
votes
1 answer
Displaying newline character in any JTextComponent?
How to display newline character in any JTextComponent (JTextArea, JTextPane)?

mgukov
- 493
- 5
- 18
0
votes
0 answers
Find location of character index in a Swing text control
I want to do some custom drawing of brackets around certain text in a text control in Java Swing. But I need to know where to draw them. I do know the exact range of characters in the text content, so I just need to be able to translate those…

mentics
- 6,852
- 5
- 39
- 93
0
votes
1 answer
JEditorPane, or any java text area fill the JFrame?
I'm writing a simple text editor in java, I have done it before now I have some new ideas, normally when I put in a JTextArea when I have a FlowLayout on my JFrame it will fill what is left of the JFrame. However this time it's not. Could someone…

NardCake
- 130
- 2
- 9
0
votes
1 answer
Using TextArea in TabbedPane
i have added a JTabbedPane with a JPanel in each tab. and a JText area within each JPanel.
the tabs can be dynamically created in the same template.
There is also a menu bar with a menu. it has options to replace an occurance of a string (eg replace…

user1542955
- 1
- 2
0
votes
1 answer
Swing: Ignore text box focus lost event when specific button clicked
I have a swing textbox that contains a value which is validated on focuslost event.
The form has many other controls, including a cancel button.
I want validation to be skipped in case focus has been lost due to clicking of cancel button.
How can…

Abhijeet Kashnia
- 12,290
- 8
- 38
- 50
0
votes
1 answer
Change cursor aligment vertically in multi-line JTextField
I have the following JTextField where I would like to change the cursor position from the middle to the TOP of the JTextField:
How do I accomplish that?

Birdman
- 5,244
- 11
- 44
- 65
0
votes
2 answers
Java GUI - displaying text in a new window from another method
I have the following interface structure: a frame in which I can browse and choose some files (in a class file), when I press a button it reads the files (in a separate class file) and sends them for some processing (in another class file, the 3rd).…

user573382
- 343
- 3
- 10
- 22