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

Trying to only allow for numbers to be entered into JTextField and non-numbers be set as 0

Having trouble guys this is for my Fahrenheit-Celsius converter class, I can't seem to get my code to recognize the following which makes sure that only numbers are entered into the text field and if not, set as 0: try { …
V4k4
  • 33
  • 6
0
votes
5 answers

How can I resize a Swing text field?

I wrote the code below: public class Information extends JFrame{ private JComboBox comboBox1; private JComboBox comboBox2; private JTextField textField[]; private JTextField jtextField; private JLabel label[]; public Information() { …
Mahdi_Nine
  • 14,205
  • 26
  • 82
  • 117
0
votes
1 answer

Multiple JComboBoxes with ActionListener

This code was taken from my original code and modified for testing purposes. Question: Why is it that after clicking on a JComboBox, I cannot click on any other JComboBoxes? Purpose: After clicking on the JComboBox, the selection gets copied down to…
Minnyme56
  • 1
  • 7
0
votes
1 answer

setText doesn't work properly if the string starts with a negative sign

So, i am making a calculator. I was trying to display the equation in a JTextField, but the equation doesn't print correctly if it starts with a negative sign. textfield.setText("-3+3"); gives output = 3+3- but the same equation when…
0
votes
1 answer

Display Jlabel based on JtextArea dynamically without button click

I have been wondering if it is possible to update JFrame or JDialogs based on the inputs inside jtextarea without button click. For an example, after i input some text in textarea. it should automatically update jlabel without the need of a button.…
user2805507
0
votes
1 answer

JtextField is not displaying full text

I have a code that generates tag by pressing button ...like you type some random word then it generates a list of tags, here's the code JButton tagGen = new JButton("GENERATE"); tagGen.addActionListener(new ActionListener() { …
0
votes
1 answer

Changing textfield to show only uppercase&lowercase

I want the first letter in a textfield to be uppercase, and when user press "SPACE" first letter to be again uppercase. I'm really sorry for asking lots of questions, but it's my first month in programming and also in java. My function for…
A. Omag
  • 117
  • 1
  • 1
  • 7
0
votes
1 answer

How can I parse a value from a JTextField into an Integer and perform some math operations on it?

So, I've been trying to make a Celsius converter in Java using swing and got stuck on getting the input from the JTextField and parsing it into an Integer so i can perform an equation on it. If I leave it as a String I am unable to do any math…
Gokata
  • 3
  • 3
0
votes
1 answer

Using values from one textField into another textField

I am trying to calculate sub-total in a separate textField from an event which involves user selecting number of rooms and number of days (based on check in and check out dates). This textField (sub-total) will effectively multiply (no of days * no…
Emanuel
  • 37
  • 8
0
votes
2 answers

Copying text from a textfield from one class to another. (Java)

So I want to use the text from a textbox in one class in a different class, but I am having trouble passing it. I more or less want to use it in an SQL query so I can get the same user info from a different table. This is first bit is my Login…
0
votes
1 answer

IntelliJ Java Gui Doesn't add JTextField

My problem is IntelliJ IDE doesn't add JTextField here is the code. public IntellJ (){ JFrame frame = new JFrame(); frame.setVisible(true); frame.setSize(400,600); frame.setLocation(400,200); …
Alper C
  • 25
  • 3
0
votes
0 answers

Automatically put JTextFilds on GUI, repaint()

How can I automatically put other TextFields on a panel when I get a number of them in another TextField?! I try to use repaint(), but I have not understood. import java.awt.Container; import java.awt.Dimension; import…
toDay
  • 1
  • 2
0
votes
1 answer

User input from a JTextField to a message box

I need to take text that a user has inputted into a text field and display it in a message box (a JOptionPane) after a button has been clicked. Here is the code I have tried: private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) { …
ZetAy
  • 1
  • 1
0
votes
2 answers

How to check which text field is focusable?

I have created buttons 0-9 as well as 4 text fields (JTextField). I am trying to allow the user to click on any number 0-9 to input into each text field. However, I cannot determine which field the user is clicked on. So when the user select the…
Yasser_1D
  • 114
  • 8
0
votes
1 answer

What does it mean when my jtextfield has "" written instead of the text I imported from a file?

I imported a String ArrayList from a file and I tried to write the first string (position 0) of the array in a JTextField. The word is not on the text field, instead of it, I have the word written there. Here's the code: txtTEST = new…
eyelash
  • 112
  • 1
  • 1
  • 11