Questions tagged [jtextfield]

JTextField is a Java Swing component that allows the editing of a single line of text.

JTextField is a lightweight component that allows the editing of a single line of text. For information on and examples of using text fields, see How to Use Text Fields in The Java Tutorial.

2960 questions
5
votes
2 answers

Java equivalent to C# TextBox TextChanged event

in C# there is an event for textboxes as follows private void fooText_TextChanged(object sender, EventArgs e) { //do something } the code in the fooText_TextChanged is fired once the text within the textbox is altered. What is the java…
Ari
  • 1,026
  • 6
  • 20
  • 31
5
votes
2 answers

JTextField limit input to certains chars only

i'd like to create JTextField with input characters limited to someting like "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVXYWZZ0123456789+&@#/%?=~_-|!:,.;" so i tried overriding public class CustomJTextField extends JTextField { String…
UnableToLoad
  • 315
  • 6
  • 18
5
votes
1 answer

JTextField key listener is one behind after pasting

I am trying to check that the text in a JTextField matches a perticular pattern, and if it does / doesn't display a message the user. This is what I have so far: public class input extends KeyListener{ // Some code here final JTextField inputField…
Andy
  • 3,600
  • 12
  • 53
  • 84
5
votes
4 answers

Check if a JTextField is a number

quick question: I have a JTextField for user input, in my focus listener, when the JTextField loses focus, how can I check that the data in the JTextField is a number? thanks
Beef
  • 1,413
  • 6
  • 21
  • 36
5
votes
4 answers

How to list suggestions to when typing inside the text field

Hi in my Java swing application I need to show all possible existing entries with same initial characters while user typing in a text field. Lets say user type letter 'A' in a text field which should be a country 'America' and 'Africa' would be…
nath
  • 2,848
  • 12
  • 45
  • 75
5
votes
3 answers

How to make a text field for searching(with tips like a google search)

I want to make a window application for PC using java swing. I would like to make a text field there. While typing to that text field I need it to show tips under that text field. And user can select the needed text from the list. The same like the…
maximus
  • 4,201
  • 15
  • 64
  • 117
5
votes
1 answer

How to restrict the JTextField to a x number of characters

I have to restrict the number of characters in the JTextField. I used the following code to do that but the problem is i am feeding the data to JTextField using the virtual keyboard. So the offset is set to 0 all the time. When i enter more than the…
Deepak
  • 6,684
  • 18
  • 69
  • 121
5
votes
3 answers

Is it possibly to create selectable hyperlink with basic Swing components in Java?

I am trying to add a hyperlink to a JPanel. I would like to make it's text blue (and underlined) and the link should be selectable (to copy some part of it). So I tried to use JLabel: yes, it allow to write something [awful] like…
Oleg Kuznetsov
  • 196
  • 2
  • 6
  • 19
5
votes
1 answer

Korean characters are displayed as empty boxes on JTextField

JTextfield does not show korean charaters properly. It shows empty boxes in instead of characters. Here is the screenshot of my application.
bahtiyartan
  • 1,010
  • 10
  • 29
5
votes
1 answer

Swing: the initial String of JTextField is an empty String

About the constructor of JTextField, the javadoc says: public JTextField() Constructs a new TextField. A default model is created, the initial string is null, and the number of columns is set to 0. But when I use this constructor, the method…
Jesus Zavarce
  • 1,729
  • 1
  • 17
  • 27
5
votes
3 answers

Getting ENTER to work with a JSpinner the way it does with a JTextField

First, to make my job explaining a bit easier, here's some of my code: JSpinner spin = new JSpinner(); JFormattedTextField text = getTextField(spin); text.addActionListener(new java.awt.event.ActionListener() { public void…
Daddy Warbox
  • 4,500
  • 9
  • 41
  • 56
5
votes
1 answer

Hebrew text in JTextField (Swing)

When I do something like fileText.setText(path) in a JTextField, it works well unless the text is in Hebrew (or combines English and Hebrew). Then I get something like this: I tried different fonts (even fonts that "Hebrew" is mentioned in them),…
user2653179
  • 393
  • 1
  • 6
  • 21
5
votes
3 answers

Can I limit the length of text in a JTextField which can be painted, while still storing the full text?

I have a text field in my application. Despite it being a text field, users sometimes paste huge amounts of text into it. Additionally, other functions of the problem set large amounts in as well. Sometimes there is so much text that the JVM gets…
Hakanai
  • 12,010
  • 10
  • 62
  • 132
5
votes
5 answers

Disabling 'paste' in a jTextfield

I have an app that is written in Swing, awt. I want to prevent users from pasting values into the textfields. is there any way to do this without using action listeners?
kilhra
5
votes
1 answer

Why does the DocumentFilter not give the intended result?

I figure this must be a simple mistake in the code or a misunderstanding on my part, but I cannot get a DocumentFilter to detect insertString events. Below is a simple filter for upper case letters, but that is not as important as the fact that the…
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433