Results 1 to 4 of 4
  1. #1
    javanew is offline Member
    Join Date
    Mar 2010
    Posts
    49
    Rep Power
    0

    Default help me with JTextArea

    if i want to show a message in the text area ?? how to make it...
    i am in class Inventory , and for example i want to write a message welcome in the text area that id declared in another class ,,


    --------Class Invenrtory ------------
    for example in class Inventory
    Java Code:
    area.setText("Welcome") << cant find area  //?????????
    here the problem with area,, cant be recognized... do i have to make import or something ?? how to make it plz help !!




    ------Class Graphics----------
    because area is declared in another class called Graphics...
    Java Code:
    JTextArea area = new JTextArea();

  2. #2
    Sno's Avatar
    Sno
    Sno is offline Senior Member
    Join Date
    Apr 2010
    Posts
    196
    Rep Power
    5

    Default

    as far as I know, Can't be done the way you want it to be.
    What is your main class? are they both GUI?

    Whatever class you have the Area in,you have to edit it in that class,

    I'd suggest create a method, in the class which JTextArea area = new JTextArea(); is in, and call if from the other class.

    Java Code:
    Class Inventory
    Graphics GUI  = new Graphics();
    GUI.ChangeArea(String Here);
    Java Code:
    Class Graphics
    public ChangeArea(String Text){
    area.setText(Text);
    }
    :rolleyes: ~ Sno ~ :rolleyes:
    '-~ B.S. Computer Science ~-'

  3. #3
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,432
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by Sno View Post
    Whatever class you have the Area in,you have to edit it in that class
    Better read about CRC (Classes Responsibilty Collaboration). Your statement is just not true; also read about the Law of Demeter for better decoupling of classes.

    kind regards,

    Jos

  4. #4
    Sno's Avatar
    Sno
    Sno is offline Senior Member
    Join Date
    Apr 2010
    Posts
    196
    Rep Power
    5

    Default

    CRC: so he could super it the parent class?
    Law of Demeter: A calls B to reach to C, but that is bad, so we should have B have C's requirements, or a direct link from A to C?

    am I understanding these correctly?
    :rolleyes: ~ Sno ~ :rolleyes:
    '-~ B.S. Computer Science ~-'

Similar Threads

  1. JTextArea
    By PhQ in forum AWT / Swing
    Replies: 10
    Last Post: 03-28-2010, 06:17 PM
  2. JTextArea on PopUp -JTextArea isn't editable
    By Richy76 in forum AWT / Swing
    Replies: 3
    Last Post: 02-01-2010, 07:51 PM
  3. Tab key in JTextArea
    By KristoZ in forum New To Java
    Replies: 1
    Last Post: 09-25-2009, 07:27 PM
  4. About JTEXTAREA
    By makpandian in forum AWT / Swing
    Replies: 4
    Last Post: 03-19-2009, 06:53 AM
  5. JTextArea
    By saytri in forum New To Java
    Replies: 0
    Last Post: 01-13-2008, 01:07 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •