🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #15938

Re: System.out.println Help!!!

#15938
From: Paul Furbacher
Date: Sun, 18 Apr 1999 00:00
69 lines
2633 bytes
Zellig" wrote:

> I have an application with a frame, in this class I declare an instance of
> another one. The second one establish an FTP connection and I put somes
> "System.out.println" to follow the process step by step. Is there a way to
> pipe the System.out to the calling frame.statusBar.

Why not create a listener interface which specifies a method
related to the change you key on:

public interface FtpProgressListener {

  public void updateProgressText(String text);

}

Have your frame implement this interface:

public class MyFrame implements FtpProgressListener {

  ...

  public void updateProgressText(String text) {
     statusBar.setText(text);
  }

  ...
}

And have your FTP worker class (it shouldn't really know anything
about frames; it should specialize only in doing FTP with the information
given to it by some invoking class) "addFtpProgressListener()"

public class FTPConnection {

  // make this a Vector if more than one listener is allowed
  private FtpProgressListener ftpProgressListener;

  ... 

  public void addFtpProgressListener(FtpProgressListener listener) {
    ftpProgressListener = listener;
  }
  // you could add a "removeFtpProgressListener()" for completeness

  ...

  public connect(...) {
    // doing ftp process here ... 
    ...
    //let's send out some progress info:
    listener.updateProgressText("connection denied");
    ...
  }
  ...
}


When you create the FTPConnection class from your application's
controller class (don't create it in a frame class -- think of your
application in terms of the model-view-controller paradigm, and 
keep views separate from models and controllers), have the 
controller class set the appropriate frame as the listener.  Remember,
other than via the "add...Listener()" method, the FTPConnection class
knows absolutely nothing about any frame class.  In fact, the listener 
could be a file, or a servlet, or a ....


Paul Furbacher
Technical Details
Message-ID: <371A9F39.4AA77B3A@bilbo.bio.purdue.edu>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <7dop7f$80f6@forums.borland.com> <7fdath$qod2@forums.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,31dab3d6de822486,start
X-Google-Attributes: gidf74b3,public
From: Paul Furbacher <pf@bilbo.bio.purdue.edu>
Subject: Re: System.out.println Help!!!
Date: 1999/04/18
Message-ID: <371A9F39.4AA77B3A@bilbo.bio.purdue.edu>
X-Deja-AN: 468146543
Content-Transfer-Encoding: 7bit
References: <7dop7f$80f6@forums.borland.com> <7fdath$qod2@forums.borland.com>
To: greg@abacom.com
Content-Type: text/plain; charset=us-ascii
Organization: Reverse Alchemy, Inc.
Mime-Version: 1.0
Reply-To: pf@bilbo.bio.purdue.edu
Newsgroups: borland.public.jbuilder.java.language