-
March 16th, 2017, 11:39 AM
#1
JTextArea Assiignmetn
The followwing assigns a value to JTextField
Code:
JTextField text= new JTextFeild();
String test= jTextField.getText);
My question is assuming I have
Code:
JTextArea tes2 = new JTextArea();
???= test2.getText()
How do I assign a variable to JTextArea ?
I tired and get the error incompatible types.
-
March 16th, 2017, 03:52 PM
#2
Re: JTextArea Assiignmetn
How do I assign a variable to JTextArea ?
You do not assign a value to a class. JTextArea is the name of a class.
You can create an instance of the class and assign it to a variable like you did here:
Code:
JTextField text= new JTextField(); // create instance and save reference
You can place a value in an instance of a JTextArea by using one of its methods. See the API doc.
The followwing assigns a value to JTextField
The description is wrong:
Code:
JTextField text= new JTextField(); // create an instance and save its value in text
String test= text.getText); // get data from textfield into the variable test
get the error incompatible types.
Please copy the full text of the error message and paste it here. It has important info about the error.
Last edited by Norm; March 16th, 2017 at 03:55 PM.
Norm
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|