CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2017
    Location
    Montreal
    Posts
    54

    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.

  2. #2
    Join Date
    Jun 1999
    Location
    Eastern Florida
    Posts
    3,877

    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
  •  





Click Here to Expand Forum to Full Width

Featured