INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Take an application program & convert to an Applet

Take an application program & convert to an Applet

Take an application program & convert to an Applet

(OP)
I want to take an application program that prints on the printer as an application program using

System.out.print("INVENTORY STATUS REPORT");

type standard out print statements to an Applet in a web screen block as though it were the printer. I get a black block & error. Surely others have tried this, to take an application and convert it to an online report.

I can't seem to find a way to convert with out rewriting

Any help?
           

Computer thought: I teach a lot of programming so I can learn. You can never learn it all.  

RE: Take an application program & convert to an Applet

(OP)
Instead of executing at the command line I just executed it as an Applet in an html file with a large box.

Computer thought: I teach a lot of programming so I can learn. You can never learn it all.  

RE: Take an application program & convert to an Applet

If you want to use a program as an applet, it has to extend Applet (awt) or better JApplet (swing). If this wasn't prepared, you _must_ rewrite it.

If you don't want to write to stdout, but to a textbox, you have to rewrite the program.  

don't visit my homepage: http://home.arcor.de/hirnstrom/minis/index.html

RE: Take an application program & convert to an Applet

(OP)
To stefanwagner

I have written several program as java applets and several as java applications.

I thought the advantage of using Standard out print statements was they could be redirected to any type of screen, printer or file.

Example:  I wrote a perl program for command execution to the printer and then just put print statements for the needed html statements around it and it became a web report screen.

I know in java it must run in a box but if the box is large enough why doesn't the output go to the screen just like a scanner type device output?

I know I have a lot to leard.

Sparkie

Computer thought: I teach a lot of programming so I can learn. You can never learn it all.  

RE: Take an application program & convert to an Applet

I don't do much with applets or HTML. Maybe you can combine both, maybe with javascript, but I have never seen such an approach.

Inside Java, you may redirect the output by binding something else to System.out. On a shell, the user can redirect it.

But the Applet in the browser?

Another way is to produce a Field in the JApplet, and write in there. IMHO, there you have more fine granulated control over actions than in html/javascript, too.

don't visit my homepage: http://home.arcor.de/hirnstrom/minis/index.html

RE: Take an application program & convert to an Applet

(OP)
Any one still out there?

There should be a way of redirecting Standard output to the printer to screen output in an applet.

Example :
Take
         System.out.println("PLAYER       SCORE1 SCORE2 SCORE3 TOTAL");

& direct it to

      g.drawString("PLAYER       SCORE1 SCORE2 SCORE3 TOTAL", 300 , 150);

--------------------------------------------------------------

I could try to rite an application that reads in a command application to the printer  "System.out.println"  & change it to "g.drawString"
  But I don't know what else I would need to do or if it can be done at all

What I would like is a statement that looks something like:

"System.out.println"   =   "g.drawString"

at the start of the program.

Sparkie
 

Computer thought: I teach a lot of programming so I can learn. You can never learn it all.  

RE: Take an application program & convert to an Applet

And where do 300, 150 come from? Did you try to redirect System.out to another PrintStream

CODE

    PrintStream printStream = new PrintStream ( // ...
    System.setOut (printStream);

don't visit my homepage: http://home.arcor.de/hirnstrom/minis/index.html

RE: Take an application program & convert to an Applet

Print statements directed to standard out from an applet show up on the Java console. You can open it from the Java Control Panel widget (among other places.)

The perl comment is a red herring. Perl runs on the server and produces output that is then rendered on the client. Java applets run on the client and have to render stuff themselves.

The idea of something like this:
     "System.out.println"   =   "g.drawString"
is just not Java-ish. If you want to examine java.lang.reflect you might get it to work, but it's not worth the effort. (You also don't want to use drawString. You want a text pane of some kind.)

You can get a Java application to run as an applet, but not just by wishing. The key distinction is that applications start up with the main method; applets start with the init method. You can have both methods in a JApplet derived class.

If you're using standard out as your output for the application, I would guess it doesn't have a GUI. That's just not how applets work.  

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close