Java Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJava Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old November 7th, 2006, 06:47 AM
Redberry Redberry is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2006
Posts: 1 Redberry User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 44 m 8 sec
Reputation Power: 0
Unhappy System.out.println conversion

Hi, i am having issues with a project i am doing currently. I am converting a command line system into a GUI based one and need to redirect all my System.out.println calls to a JTextArea. (very simple conversion currently) I have numerous classes currently all making println calls so without making my JTextArea global i'm not quite sure how to fix this in a clean (and preferably object oriented) way.

Any help would be very much appreciated. Thanks.

Reply With Quote
  #2  
Old November 7th, 2006, 09:19 PM
daniel_g daniel_g is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2006
Posts: 60 daniel_g User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 21 h 3 m 50 sec
Reputation Power: 3
I guess what you are really looking for is the setText() method.

First, for whatever object you want to return, create a function, let's use a String as an example:
Code:
class A{
  String name;
  public A(UserInput){// constructor
    name = UserInput;
  }
  public String Hello(){
    return "Hello " + name + "!";
  }
}

Then on the other classes, you can get the value of str by creating a new instance of class A:
Code:
class GUI{
  public void toTextArea{
    A newInstance1;
    newInstance1 = new A("Redberry");// sets value of contructor
    // now we are ready to send stuff to the textfield:
    YourTextfield.setText(newInstance1.Hello());// gets the return value of the function Hello()
  }
}  

And on the texfield you should see
Code:
Hello Redberry!

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJava Development > System.out.println conversion


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT