Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Take an application program & convert to an Applet

Status
Not open for further replies.

PROFESSORSPARKIE

Instructor
Oct 24, 2002
181
US
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.
 
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.
 
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:
 
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.
 
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:
 
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.
 
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top