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

Count how many times a word has been repeated in a JTable in Java Netbeans

I have tried putting rows in a JTable and that is what I managed to do. My variable input stores text from a textfield. What I want is that if an input is repeated, the word appears in one column and in the other column the times that it has been…
Sebastian
  • 3
  • 1
0
votes
1 answer

Second JPanel and JTexField look too cramped

I have an application where I use two JPanels. One of them is a PaintPanel. The second panel,the jtextfield and the jtextarea work fine but they look too cramped against the right side. I tried changing the sizes with setSize() but it didn't…
user13614125
0
votes
1 answer

JTextField and DefaultButton regarding ENTER key consumption

In the SSCCE bellow, I have a JTextField with a registered KeyListener. The KeyRelease function, will show a JOptionPane if the key is ENTER. The problem is: if the user validates the JOptionPane using the ENTER key, the option pane will appear…
Staifi78
  • 3
  • 1
0
votes
2 answers

how to set a range of number (between 1-150) for a JTextfield in Java Swing

I am programming a GUI Application to enter the height width and length of a workpiece. When the user clicks on the "Test" Button it should be warned (through a jlabel) if the fields are empty and if the input is bigger than 150. I am struggling…
0
votes
1 answer

Setting the height of a JTextFrame

The following class creates a form (Jpanel) tasked with acquiring multiples Strings from the user and do something with them. It it functionally working, but it bugs me that the height of the JTextFields (a component that allows for the modification…
Asghabard
  • 191
  • 13
0
votes
1 answer

Trying to update a Java Swing JLabel text field to display new text once an IF condition is met

I'm working on a simple GUI project to get the foundations of Java Swing. I created a Rock Paper Scissors game which you play against the computer which i implemented a GUI for My text based GUI Form for Rock, Paper,Scissors My problem is that once…
Megz0192
  • 1
  • 2
0
votes
0 answers

JTextField is locking input

I'm using a JTextField (xInput) to input an x coordinate: xInput.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(DocumentEvent e) { updateX(); } public void…
Box
  • 1
  • 3
0
votes
1 answer

Setting size of JTextField inside a JTable

I've set the size of my JTable column to 200 (using setPreferredWidth()), and the size of my JTextField inside it to 100 (using setSize()). Still, I see my text field stretched out to the entire 200 pixels of the column, ignoring the size I…
Danny
  • 1
  • 1
0
votes
0 answers

Populating JTextField with Array data

I am making a program that lets you choose a player from a JComboBox drop down list that has values passed from an Array, this array is a converted ArrayList from a BBDDClass that contains values of players from a Player class. JCombo: …
0
votes
1 answer

How to display a textfields text from one class into another class' label

I'm struggling to figure out how I can put the text I have in my textField in Frame 'Test1' into my label in Frame 'Test2'. Please could somebody help, here is all my code: package Frame; import java.awt.BorderLayout; import…
0
votes
1 answer

ActionListener knowing which component triggered the action

I would like to have an actionlistener to be able to figure out the source as shown in the code below. How should i implement this? JTextField tf1 = new JTextField(); JTextField tf2 = new JTextField(); ActionListener listener = new…
Cherple
  • 725
  • 3
  • 10
  • 24
0
votes
1 answer

How to customize the View of Java 9+ JTextField for different code-point of the text in its Model?

All Java Swing components use MVC, for each component there is a Controller, Model and View. Particularly, JTextField uses PlainDocument as its model to fetch data and uses TextUI as its view to render the data. The link in JavaDoc : JavaDoc…
0
votes
1 answer

How to show the coordinates of my mouse in a couple JTextField?

I new here, and I'm a beginner about developing. My problem is that I have couple of JTextField controls inside a JPanel which is inside a JFrame too, and the text field doesn't show the text that I pass by a method, and I don't know why, because…
0
votes
2 answers

JButton that highlights next/previous match in JTextArea JAVA SWING

I am trying to implement buttons that search a specific word in JTextArea in my Java Swing application. Can anyone help me to implement buttons to highlight the next and previous match ? Please review my code for searchbutton aswell. For now it…
0
votes
4 answers

How to edit a txt file using JTextField with a specific format?

I am creating a inventory program that involves the cashier and the admin mode. The admin mode can change the item name, price and stocks of an item. All items are stored in a txt file. The content of the txt file (it has slashes to separate names,…