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

How do I add variables in JOptionPane.showInputDialog

I´m really new to java and GUI´s but I´m trying to implement the "guess the number game" to an app. I want to change the max and min variables here n = Integer.parseInt(JOptionPane.showInputDialog ("Choose a number between [%d,%d]:"), min, max); to…
LASO
  • 1
  • 4
0
votes
1 answer

JTextField.getText() inside of actionListener fails to return the proper String

I have run into the issue of not being able to collect the real text from my JTextField when calling getText(). I have provided a simplified version of the code I was running that includes only the aspects of the program to where it will reproduce…
0
votes
2 answers

JTextfield Validation for numbers?

I am trying to validate my roll no (input of integer value) from JTextField. Well my code is compiling but while running it is giving me an error NumberFormatException. Here is my validation code public int rno_vd() { int a=0,b=0,c=0,x=0,y=0; …
0
votes
1 answer

Google's interactive text fields in java swing

I am struggling with something regarding java swing....I need to know how the linear text fields in most google apps are made....the ones where there is only one line in the bottom and how can I make them interactive. I don't need the app designer…
TSS DRX
  • 25
  • 6
0
votes
1 answer

BlockingQueue can't read String from JTextField

I am having an issue creating a custom console, on the following code: public class UserConsole { protected static BlockingQueue inputData; private final static JTextArea textArea = new JTextArea(); private static JTextField…
CLR 123
  • 161
  • 1
  • 8
0
votes
2 answers

How to read a value from keyboard using Swing interface

I'm looking for an simple example to explain how read a simple value from a text field for using in my program. I saw a lot of complicate examples with a lot of many lines but, unfortunately, I haven't found a simple example to clear me. I have an…
0
votes
1 answer

Java/Swing - Set title for TextField

I could not find any class to set a title for TextField. Therefore, I decided to make one. My question is really simple. Do I really need to include JFrame in my class or maybe there is a different way to accomplish this problem. Here is my GUI…
0
votes
1 answer

How do you make a JTextField's number bigger than another JTextField's number?

I'm trying to get a JTextField's number greater than another JTextField's number for my Tic Tac Toe project, but I keep getting exceptions.. For instance, if gridSizeField's number is 6, than playersField's number would not be 5. I want it to be 6…
0
votes
1 answer

Update/Fetch/Sync a JTextField input by user in a class to a JTextField of another class

public class FormattedName extends javax.swing.JFrame { /** Creates new form FormattedName */ public FormattedName() { initComponents(); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT…
reukEN11
  • 121
  • 1
  • 2
  • 9
0
votes
0 answers

How can I make my jTextFields display one after another

I am coding a game in java. I have two jtextFields named dice and dicecom. I want such that when I press a jButton first a random value between 1 to 6 will be shown on dice, then there shall be some time gap of about 2 seconds after which a random…
0
votes
0 answers

Put JTextField text into JList

So the problem I'm having at the moment is that I need to put text from a JTextField into a JList whenever I clicked a JButton. But how do I do this?
0
votes
2 answers

Getting the position of a Swing Component relative to the screen

I have a class called SuggestionField It will show the user a list of items to autocomplete his input. he let of inputs is displayed in a JDialog(suggestionFrame). I need to set the JDialogs position to be below its parent, but I can not get the…
Parzavil
  • 388
  • 3
  • 13
0
votes
1 answer

fixing the size of a JTextField within a GUI

I have the following code to create GUI. The issue i am having is that the JTextField appears to expand as the GUI is resized. I want the JTextField to stay the same size as the GUI is enlarged. The JTextField also seems to reside at the bottom of…
inky
  • 137
  • 7
0
votes
1 answer

Action Listener for a JTextField fails after first "use"

I'm trying to create a small program, where you have to guess words while you are shown a matching anagram. My code is like: JFrame frame = generateJFrame(BACKGROUND, FOREGROUND); JLabel display = generateDisplay(BACKGROUND,…
Shao
  • 59
  • 1
  • 8
0
votes
1 answer

Why doesn't JTextfield in java display text at runtime?

Hope you are all well! Hope you understand my Java question... I have created a JFrame window with text to display, but it doesn't display at run-time (as it should) unless I maximise the Frame window. Can't understand it? Here's some code: package…
hm087ster
  • 17
  • 1
  • 7