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
0
votes
1 answer

JText field, notice update only when user changes something

I want to know if there is a way to notice if a listener is changing the text of a JTextField or if it is done by .setText(); I need to seperate between both cases, beacause it need to do different things when accesed by a user or by the programm.
carlos.gmz
  • 100
  • 8
0
votes
1 answer

How do you obtain 2 inputs from a user in Jtextfield?

I want the user to type a name for player one and press enter and then for the textfield to be blank again so that the user can type in a name for player 2. so far I can only get player one's name as input but not player two. For some reason my code…
0
votes
0 answers

Drawing a line with JTextField values, what do I do wrong?

I need some help with my code. I would like to draw a line and afterwords some other shapes. I thought a line would be a good start. I am trying to get the x and y values out of a textField, and it works. Unfortunately the line itself does not…
Sebson
  • 1
  • 1
0
votes
1 answer

JTextField not empty for integer input

I'm trying to create a method that validates that the user did not leave the JTextField empty. No error handling is needed, I just need to make sure it is not empty and the user entered the number of meals. I wrote the following: private void…
Fathi
  • 9
  • 1
  • 6
0
votes
0 answers

JTF8DocumentFilter in java swing to allow only numbers have an error

I have a JTF8 DocumentFilter class to make Text accept only Numbers (with (-) numbers also), but there's an error on it because it also allows me to type (000) or (00). I need to customize it to deny typing (00) or (000), and allow it to type only…
Adeeb Mark
  • 131
  • 1
  • 8
0
votes
0 answers

How to check if JTextField equals certain value in Java?

I'm trying to make a program where the user pick the operation and then tow random numbers will appear in JTextField, and user should put the answer in another text field, I'm trying to check weather the result equals the answer text field or not…
REEMA
  • 1
  • 1
0
votes
1 answer

Is there an way to remove a JTextFiled if a certain item in JComboBox is selected in java?

I have a registration panel where if student, instructor, and course administrator can register so if student is selected it should show something like this when Student is selected: and should show like this if other two are selected like this…
Nutan Panta
  • 65
  • 2
  • 7
0
votes
0 answers

How to create a contact form delete button in java to delete selected element?

I am a beginner who is struggling to create a button in my contact form project in java on IntelliJ. I am trying to achieve this: when the button is clicked, the name is deleted from list on the left and all of the text fields are cleared. I would…
0
votes
1 answer

UPDATE of How to get string from JTextField and save it in variable?

I recently run in to same problem as this guy 4 years before. He get some answers there but non of it work either for him or me and then the question was not updated anymore. How to get string from JTextField and save it in variable? The point is to…
Rjelinek
  • 26
  • 6
0
votes
0 answers

How to allow Enter key to proceed to the next text field?

I have 2 JTextField components and I want the typing to proceed to the next text field when Enter key is pressed. How to achieve this?
0
votes
1 answer

How to remove focus from textfield and set it on button?

It is the simple counter gui program in these program by pressing right arrow counter is incremented by 1 but the problem is whenever i run the program then pressing the right arrow the counter is not increment by 1 but by pressing the right arrow…
yash1307
  • 9
  • 1
  • 3
0
votes
1 answer

Adding JTextField yields empty JFrame

I am pretty new to this and I am following a tutorial with everything working great. However, when adding a JTextField, the JFrame turns into a plain gray background. I am calling the GUI class that makes the JFrame from the Main.java, so I tried to…
0
votes
1 answer

how to build a JFrame window with a graphic area paintComponent with JTextField, JButton and JLabel?

I've been searching in google how to build something that looks like in the image. Text boxes, labels, buttons with actions and a graphic area all in one JFrame, but I only can find them separated. I mean, I understand how to build them separated…
Lothar
  • 39
  • 5
0
votes
1 answer

Scrollbar not appearing when size of JTextField goes over its predefined size

I'm trying to implement a scrollbar in a JTextField using JScrollPane. this is what I have: import javax.swing.*; import java.awt.*; public class WordList extends JFrame { public static void main(String[] args) { …
Kcits970
  • 640
  • 1
  • 5
  • 23
0
votes
1 answer

JTextField value is not updating after button click

I am new to java swing. I am creating application for patient registration using Swing. There is a button called Clear, that button should clear the input data from the text fields.When button is InputPanel.clear() set the values correctly.But it is…