Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: How can I append text in JTextArea from another class

  1. #1
    Junior Member
    Join Date
    Dec 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How can I append text in JTextArea from another class

    i have two classes. a TextArea in in one of them and i want to append text to it from another class. can somebody give me a code example that can so this


  2. #2
    Junior Member
    Join Date
    Dec 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How can I append text in JTextArea from another class

    I have tried something like this but it is not showing anything in the textArea. i have two classes A and B
    Class A

    Class A extends javax.swing.JFrame{
    private JtextArea myTextArea;
    A( ){
    myTextArea = new JtextArea;
    }
    public void setArea(String mess){
    myTextArea.Append(mess);
    }
    }

    Class B
    Class B{
    A newA;
    B( ){
    newA = new A;
    }
    //i have this line which is supposed to append text in myTextArea in class A
    newA.setArea(“message”);
    }

  3. #3
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: How can I append text in JTextArea from another class

    myTextArea.Append(mess);//should not compile
    myTextArea.append(mess);//should work

Similar Threads

  1. How To: Add line numbers to your JTextArea
    By Freaky Chris in forum Java Swing Tutorials
    Replies: 11
    Last Post: October 15th, 2013, 10:22 PM
  2. how to load a class and type cast to that class?
    By chinni in forum Object Oriented Programming
    Replies: 2
    Last Post: November 9th, 2009, 10:18 AM
  3. help writeing to a jtextarea from a diffrent class
    By mdstrauss in forum AWT / Java Swing
    Replies: 6
    Last Post: October 6th, 2009, 09:56 AM
  4. Convert contents of JTextArea / JEditorPane to PDF
    By rangarajank in forum File I/O & Other I/O Streams
    Replies: 2
    Last Post: September 30th, 2009, 02:38 PM
  5. Replies: 1
    Last Post: May 21st, 2009, 03:41 AM