Problem: Grabbing Ints from JTextField
Code :
private JTextField JTextField1;
ints number1 = JTextField1;
JTextField1 = New JTextField("",10);
add(JTextField);
Anyway to do this, The error is Cannot use JTextField for ints, Something like that, I had this error like a week ago and plan to rewrite it.
Re: Problem: Grabbing Ints from JTextField
A text field can contain a String. You need to use a text field method to get that String from the text field.
When you get its contents into a String you can use the Integer class parsing method to convert that String into an int.
Re: Problem: Grabbing Ints from JTextField
Is there a more simple way to do this?
Re: Problem: Grabbing Ints from JTextField
Can you explain what you are trying to do?
Re: Problem: Grabbing Ints from JTextField
Use ints in a jframe? Rather than having to put the information in eclipse itself, i want to be able to put them into a jframe.
Re: Problem: Grabbing Ints from JTextField
There is no way for a user to enter int values into a JFrame. A user can put String data into a textfield that is shown in a JFrame.
Or you could use the Scanner class with a console window and use its nextInt() method to read and convert user input into int values.