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

How to get text from same Text Field used multiple times in Java Swing

I'm trying to get text from a JTextField iterated through my code (apparently, I can't add a different text field from a button). Here's what the "Add Items" button do: addButton.addActionListener(new ActionListener() { public void…
RAZ0229
  • 193
  • 4
  • 14
0
votes
1 answer

Validate input of jTextField using setter java

I implement OOP in my Java assignment. But when I started creating user interface and accept the input I have faced a problem. I wanted to validate the user input of jTextField from user interface using my setter method. I want a pop up to appear…
random
  • 95
  • 1
  • 10
0
votes
1 answer

How to replace a single component inside a JPanel that is one of the frame's panels

I'm using IntelliJ and I have a form full of components placed inside several JPanel containers. I would like to change only a single component of a single panel when the button is pressed. I tried to remove all the components of that panel and add…
0
votes
1 answer

Can someone tell me why my program isnt running?

import java.awt.*; import java.awt.event.*; import javax.swing.*; public class RecallStudy extends JFrame implements KeyListener, ActionListener { //CREATION OF ELEMENTS JLabel recallLabel; JTextField…
0
votes
1 answer

Sending a Text from JTextfield to another Jtextfield using the enter button

enter image description here What i need is to be able to create this box. What I need is for the text to be entered into the first box on the right, and once the enter button is pressed, the text on the right goes to the text on the left. The left…
0
votes
0 answers

How to apply Swing animation in Bubble sorting algorithm?

Am trying to visualize the actual swapping between arrays indexes but I am unable to make it slow to visualize. Want to make a pause in swapping so I can actually visualize it. import java.awt.Color; import java.awt.Container; import…
0
votes
2 answers

JTextField size

I have a JPanel like this: GridBagConstraints constPanelInfo = new GridBagConstraints(); panelInfo = new JPanel(new GridBagLayout()); JLabel sensor1 = new JLabel("Sensor: "); constPanelInfo.gridx = 0; constPanelInfo.gridy = 0; …
Roman Rdgz
  • 12,836
  • 41
  • 131
  • 207
0
votes
1 answer

Swing textbox with icon

I'm writing a plugin for IntelliJ and need to allow the user to select a file. All the coding works fine but I can see in some other parts that they use a textbox with a right-aligned flat icon. JTextField with flat icon I was wondering if anyone…
Tim
  • 11
  • 4
0
votes
2 answers

Show message when JTextField content is not equal to a certain int

I am figuring out how to show up a message-dialog-box whenever the user doesn't type the number 7 in a JTextField: This is the code I am trying in the button click event: try { Double user_input =…
HOTOMOL
  • 71
  • 6
0
votes
1 answer

How to update an array on the same text field on Java?

I want an array of letters based on the desired quantity to be displayed in a text field each time the button is pressed, example: desired quantity: 3, selected letter "A", therefore the layout would be something like this: AAA. After that I want to…
Daniel
  • 147
  • 1
  • 7
  • 19
0
votes
1 answer

Escaping out of text field based search bar

I have a menu bar with a search-bar that is implemented with a JTextField like this: public class Ui_Frame { private static JFrame f; private static DrawPanel drawPanel; public static void main(String[] args) { …
krise
  • 485
  • 1
  • 10
  • 22
0
votes
1 answer

How to make with JTextField and JButton a menu with name filling functions?

So i am trying to make a Panel where the player configures the names of the players in a local board game. I want them to be able to add players between 2 and 6 so by default i have made the panel show up 2 JTextField boxes for them to add names and…
Kamora
  • 83
  • 7
0
votes
0 answers

How to send different components and then check their type?

So I have a JComboBox and JTextField in view. I want to send them to model so I tried: functionName(component); And then in model: functionName(JComponent component) { switch(component.type){ case JComboBox: …
0
votes
1 answer

Java Swing: Display validation rule to user on JPanel

I have a JPanel which contains a number of JTextField(s) that have a length limit of a few characters (implemented by a custom PlainDocument). I want to display a text in red font at the top left of the panel saying, "**Fields allow a max of 20…
Vinayak
  • 11
  • 3
0
votes
1 answer

How to set letter spacing in Java Swing GUI?

In CSS, there is a letter-spacing property that we can use to increase spacing per letter in a word. Is there a way I can increase a letter space or text space? I was hoping I can increase the space of the text in a field.
user14104923