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

Set JTextField from value of Thread on Button Click not working

I'm trying to create a simulator that will print what color a traffic light is currently at into a JTextField when the "start" button is clicked. However, clicking the button doesn't do anything. I have System.out lines that work with the same…
nbaq
  • 45
  • 6
0
votes
1 answer

How to remove content of JTextField while DocumentListener is running?

for the following Code I get an IllegalStateException (Attempt to mutate in notification): private class DocumentHandler implements DocumentListener { public void changedUpdate(DocumentEvent ev) { // unused } public void…
0
votes
2 answers

Finding out/calculating the width of a symbol

Finding out/calculating the width of a symbol panel.add(textfield,BorderLayout.SOUTH); system.out.println(textfield.getWidth()); System.out.println(textfield.getHeight()); both return 0, which should be more graphically returns, i mean returning…
0
votes
1 answer

Creating JTextFields in a for loop to calculate pow of a number stepwise

I have a JFrame in which the user shall enter 2 numbers and the powers of that number should be displayed step-by-step. This is what I have so far: This is what it should look like: The problem is this line: txt3.setText(output); because it just…
stepbysteptomathpro
  • 455
  • 1
  • 7
  • 16
0
votes
1 answer

How can I get the value of the 'Array of JTextField' and store it in an Array Integer?

I have two arrays of JTextField and I want to store it into another array. JTextField[] proText, atText; int[] burst, arrive; I have tried the usual way of the passing the value of the array while(true){ if(atText[lowerBound].getText() != "…
knhrvs
  • 3
  • 3
0
votes
2 answers

JTextField only shows a slit with GridBagLayout, solutions i found for similar problems didnt work

So have a JFrame which contains 2 JPanels and one Button using the GridBagLayout. But the problem lies with the Panels which also use GridBagLayouts. JPanel p_addIng has has a 3x2 Grid with two JTextFields in the first column one the the size of the…
jonas
  • 164
  • 1
  • 11
0
votes
0 answers

why does the JTextField go beyond the border of the JFrame?

Good evening. I'm having a strange problem with the JTextField in my gui for a calculator. in few word the Text field goes beyond the border of the frame (which is 500), the strange thing is that i've set the lenght bound of the text field as the…
0
votes
1 answer

Why is my left TextField in FlowLayout not showing text prompt but the right one does?

Hi why is my left JTextField not showing the text prompt but my right one does? The JTextField i am talking about is called gname . The JTextFieldwhich is working is called fid . The Programm is supposed to search for both JTextField values in a sql…
0
votes
0 answers

JTextFields--unable to edit,input text

I have two JTextFields that cannot be edited/clicked on unless I click outside the current JFrame window. I have tried to setEditable, setEnabled, requestFocus(), etc to true but all do not work. Any suggestions? I do not know how to replicate the…
Miguel Z
  • 1
  • 2
0
votes
2 answers

Dynamic update of visual components in swing

I have a question regarding the possibility to dinamically update the visual side of a swing application. I have created a small program, that works without any compile/logic errors and it does it's thing but it has a flaw. It does not…
zypa
  • 303
  • 2
  • 13
0
votes
1 answer

Safeguard a String from being null in JTextfield using if-else

I'm a novice in Java. I want to remind my user if they didn't enter a String in the JTextField, so I use an if-else statement to safeguard. However, the reminder doesn't jump out when I test it. How do I safeguard a string from being null in text…
yijia
  • 1
0
votes
2 answers

getting refrence for JTextFeild in actionListener

I am trying to use getText() method from a JTextFeild in an ActionListener attatched with it ... the problem is I don't have a reference that points to it ... that is I'm adding those textFeilds with in a loop that takes a string from arraylist and…
0
votes
0 answers

Aligning JTextFields, JLabels, and JButtons in a JPanel

I have a public class which extends from JFrame. Inside this class I Have a JPanel, which I'm adding fields and buttons. But the problems is that no matter if I set .setLocation, Java will ignore it and my components are not being alligned as I…
Gonzalo Dambra
  • 891
  • 2
  • 19
  • 34
0
votes
1 answer

JTextfield array, retrieve name and text

I have an array of JTextField and when a JTextField is modified I want to have the name of the JTextField and the text. while ((line = bufferedReader.readLine()) != null) { // 1 by 1 line of file if (f == 6) { g++; f = 0; } …
0
votes
2 answers

Swing java JComboBox disappears whenever I write in JTextField

I have a main JFrame pane using Swing in Java with a JComboBox embedded in it with a number of selections. Everything initiates well on opening but when I write inside the JTextField, the words in the JComboBox disappear. I'm initiating my…
Katie Melosto
  • 1,047
  • 2
  • 14
  • 35