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
2 answers

Java: how to allow backspace being pressed in JTextField

I've made a JTextField that restricts characters being entered unless it's numbers, letter "e", or comma . But now I realised that it restricts backspace being pressed to. How can I change it? I'll add the code, where it checks what key is being…
guilt
  • 49
  • 7
0
votes
2 answers

How to make a search button action event?

The GUI has a search bar that when the user types a book and click search, it pops up on the JList. But I don't know how to write the code for it. public void actionPerformed(ActionEvent e) { if (e.getSource() == searchButton) { // Action…
Wietlol
  • 69
  • 1
  • 10
0
votes
2 answers

How do I create an array of JTextField and retrieve the text from an array of String?

I am quite new to Java and learning as a student. I hope you can understand me. As you can see from the code below, I've only coded the frame and the label. The user should be able to write some song recommendations. There should be at least a few…
ichigo
  • 11
  • 1
0
votes
0 answers

Searching applicants by email through the Queue Class (listnode) fromt he GUI of the program

I have a program for my homework where we add/edit/remove/allocate students who have applied to uni/college with the contact details and ucas points. One of their contact details involves their email. Basically I want to find an applicant I want to…
Sean
  • 1
  • 3
0
votes
1 answer

How to get text from jtextfield and skip to jtable row based on text?

I have 1 column with 100 names, all from A to Z. I have to choose 1. I want to be able to insert a few letters into a jtextfield, press enter, and have the row be selected that matches the text. How do I do this? An example would be, I type "Bro",…
user12173484
0
votes
1 answer

Java Text Field Input Issue

So I'm trying to have users type in an answer to the question via a text field, but the way I have it set up, the name field is only being stored inside the ActionListener Class and not the QName class. I've checked by trying to output Name using…
Vinh Quach
  • 11
  • 2
0
votes
1 answer

JTextField setDocument overwrites text

I created a JTextField (either with setting the text after the creation or in the constructor). After that I added a Document (setDocument) to the textfield and wondered why the text value of JTextField was empty. Example: JTextField field = new…
Liso
  • 195
  • 5
  • 15
0
votes
1 answer

How to query SQLite database based on textfield entry with "0's"?

I am creating a small database that can store the records of my job numbers. I want to start each job number with 2 zeros (00) and then put the number of the job after. Like this "001-2019". When I go to query the database, it doesnt work. But if I…
user12173484
0
votes
2 answers

How to: get input from JTextField after button is pressed

I am fairly new to Java and just wanted to ask about ActionListener method. I've created a GUI and in one panel I want to ask the user to input values of x and press submit. It looks like this: f(x)= [input field] - [input field] ^2 (submit…
guilt
  • 49
  • 7
0
votes
0 answers

Why does JPasswordField class exists in Java Swing?

I know what the JPasswordField class does, and how/when to use it. This is not the question, just for clarity. What I don't understand is why its functionality can't be part of JTextField: What problem would arise if they made…
Diego Queiroz
  • 3,198
  • 1
  • 24
  • 36
0
votes
1 answer

How run .sh script with user input from textfield in Java?

I try start .sh script with user input from txtfield. Idea: user write parametre in txt fild. When push the button and script start with this parametre. My code: private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { …
0
votes
1 answer

how to use JTextField to show a negative or positive result using ActionListener on the JTextField itself

My program is supposed to ask a user to write a number in a JTextField and then show the result if the number is negative or positive in another JTextField that is disabled. All of that must be done without a button. import java.awt.*; import…
0
votes
1 answer

Check user entered string against String and Int

I'm trying to accept a user field in the form of a jTextArea (Search box). Then take this text and compare it against an ID OR Name and return if its inside of any. Compare User Entry to ID Compare User Entry to Name Essentially check the user…
0
votes
1 answer

Implement a simple calculator GUI using Swing controls

I want to make a simple calculator using Swing components with only one JTextField. In the actionPerformed method where ActionEvents will be implemented, I want to know: what logic is required to perform a particular action when user Enter the…
Kashif
  • 19
  • 8
0
votes
1 answer

JTextBox and all following JComponents don't show up

I want do design a simple login format and in order to do so I want two JTextFields for Username/Password and a Login Button. The Login button is display as expected but when I add the JTextField, nothing shows in my JFrame. Would be nice if someone…