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

MigLayout: Put two JLabel on the same line separated by JTextField

How do I set two JLabels separated by a JTextField in the same line? I am using MigLayout. I have the following code JPanel helper = new JPanel( new MigLayout() ); helper.add( new JLabel( "Threshold:" ), "" ); threshold = new…
Silver moon
  • 229
  • 3
  • 15
0
votes
2 answers

Which Swing Component to use?

I am a newbie to Java and GUI programming. I have the following question. In my GUI, I have a JTextField with a JLabel which reads "Radius". Now I want to put an icon next to the JTextField with a question mark which on clicked explains in details…
Silver moon
  • 229
  • 3
  • 15
0
votes
0 answers

How to print values of JLabel and JTable in JPanel

So I want to print the values of my JLabel, JTextField, and JTable within the JPanel and not the JPanel itself. What I always search always result in printing the whole Panel which includes buttons that is unnecessary: image I did find something…
Eamyr
  • 11
  • 4
0
votes
2 answers

Java netbeans - how assign jtextfield value to zero if jtextfield value is empty

double B=Double.parseDouble(emp_txt2.getText()); double C=Double.parseDouble(nopay_txt3.getText()); double E=Double.parseDouble(wop_txt4.getText()); double F=Double.parseDouble(wop_txt5.getText()); double f =B+C+E+F; String p…
Dalvik
  • 3
  • 2
0
votes
1 answer

add JTextPane string to JComboBox

I have looked at similar questions on this site but I cannot seem to grasp the concept, so I have to post my own question to get an answer specific to me. I am trying to get the text entered into the JTextField txtAddEng added to the JComboBox…
0
votes
1 answer

Formatting JLabel/JTextField text?

So I'm trying to make a very basic app that counts(adds a number to 0 every second) when you hit a button then displays it in a label and a text field. Since I'm using doubles the text output looks like this, for example: 2.34555555555555. I want it…
0
votes
1 answer

how do you set text on JTextField that carries the java bean value after clicking submit

When clicking a JButton (submit) from one class another class is supposed to replace the text of a JTextField. The new text value is collected from a bean. The new value appears on the console doing system.out.println but why doesn't it replace the…
PattyZ
  • 1
  • 2
0
votes
2 answers

button action listener for text field doesnt work

I tried to make this GUI program which take input from the user by text field and should return it with uppercase convertion: import javax.swing.*; import java.awt.*; import java.awt.event.*; public class gui { JTextField textField; JFrame…
0
votes
1 answer

Coin flip simulation: Counting heads / tails

I am trying to simulate a coin flipper using Java and window builder. I have a button called "Flip" when that button is pressed the coin image changes depending on which number the random generator I created generates. I now am trying to figure…
amiej33
  • 19
  • 5
0
votes
2 answers

Adding multiple JTextFields under one ActionListener?

I am working with JTextFields, JComboBox, and buttons. When I select some information from JComboBox, I press the button. That creates a JTextField. and sets the text of the JTextField by using the getSelectedItem().toString() method. The issue I am…
razshan
  • 1,128
  • 12
  • 41
  • 59
0
votes
1 answer

How to retrieve data from JComboBox and store it in JTextFields?

I have a JComboBox. I want to retrieve the data from it. I know I use the getSelectedItem() method. But then once I get it, I want it to convert it to a String somehow..or ultimately, display it on a JTextField. String[] fluids = { " ",…
razshan
  • 1,128
  • 12
  • 41
  • 59
0
votes
5 answers

Is there a way to convert a String to JTextField type?

How do i convert a string data type to JTextField type. I have set of text boxes in a window and i want to fill it from database using a loop. I am constructing a string with the content same as text box name and now i want to change the data type…
Deepak
  • 6,684
  • 18
  • 69
  • 121
0
votes
1 answer

JTextField window does not appear

On a panel, I'm adding a textfield and a button. I'm trying to change size or position of the textfield but it doesn't change. See example image /** * * @author Tsiatas */ import javax.swing.*; public class MyFrame extends JFrame { private…
0
votes
0 answers

JTextField or JFormattedTextField for digits, comma and dots?

I need to restrict a text field input to just digits, comma and dots. I could do this using a DocumentFilter and a JTextField but what if I wanted to use a JFormattedTextField? I've tried to look at some examples but I didn't understand.
JessicaJ
  • 31
  • 5
0
votes
1 answer

How do I set the text in it at the beginning when the dialog opens?

I have the following code that displays a JDialog, it shows a text field, I assume it's a JTextField. How do I set the text in it at the beginning when the dialog opens? JOptionPane pane = new JOptionPane("",…
Frank
  • 30,590
  • 58
  • 161
  • 244
1 2 3
99
100