• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

The System.out .println("") command is not working in Applet.

 
Haifeng Jiang
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I try to print something to the console, I failed. Below I add the print command to actionPerformed mothed. But don't know why it is not working. Anybody know the cause? Thanks in advance.
public void actionPerformed(java.awt.event.ActionEvent e) {
System.out.println("c.actionPerformed(java.awt.event.ActionEvent e)-=----------------------------------------------------");
if ((e.getSource() == getBuLogon())) {
System.out.println("-=----------------------------------------------------");
conn0(e);
} else if ((e.getSource() == getBuChangePassword())) {
System.out.println("-=----------------------------------------------------");
_appletDirector.askUserForChangePasswordDetails();
}
String servletVersion = getAppletDirector().getServletVersion();
System.out.println("Servlet Version : " + servletVersion);
}
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello "Kanawalo"-

You may have missed that we have a policy on screen names here at JavaRanch. Basically, it must consist of a first name, a space, and a last name, and not be obviously fictitious. Since yours does not conform with it, please take a moment to change it, which you can do right here.

As to your question, you're looking at the Java Console (which is different from the command line prompt where desktop applications would print their output), right?
 
Haifeng Jiang
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ulf Dittmer:
Hello "Kanawalo"-

You may have missed that we have a policy on screen names here at JavaRanch. Basically, it must consist of a first name, a space, and a last name, and not be obviously fictitious. Since yours does not conform with it, please take a moment to change it, which you can do right here.

As to your question, you're looking at the Java Console (which is different from the command line prompt where desktop applications would print their output), right?


Thanks. I have updated my name. And for the problem I will investigate by myself. Thanks for your advice!
 
Tim Holloway
Saloon Keeper
Posts: 18359
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just out of curiousity - your last name is Eric?

Anyway, System.out.println is sort a place of last resort for displaying data. It's OK for testing and one-shot debugging, but you shouldn't use it for production programs unless they're purely command-line utilities like the Unix filter programs. You can never be sure where (or if) a System.out.println will display.

For applets, however, you normally will see the output appear in the Console (debugging) window. That's not a good place for production, since it's not visible unless the user explicitly makes it visible - it's intended for debugging, not general use.

You can get much finer control and routing of messages by using one of the Java logging subsystems such as Log4J, but once again, that's not something that you'd normally present to the user. Usually applets would pop up a message box dialog.
 
Haifeng Jiang
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Tim Holloway:
Just out of curiousity - your last name is Eric?

Anyway, System.out.println is sort a place of last resort for displaying data. It's OK for testing and one-shot debugging, but you shouldn't use it for production programs unless they're purely command-line utilities like the Unix filter programs. You can never be sure where (or if) a System.out.println will display.

For applets, however, you normally will see the output appear in the Console (debugging) window. That's not a good place for production, since it's not visible unless the user explicitly makes it visible - it's intended for debugging, not general use.

You can get much finer control and routing of messages by using one of the Java logging subsystems such as Log4J, but once again, that's not something that you'd normally present to the user. Usually applets would pop up a message box dialog.


Thanks. It is good for ppls to remember me. :-)
My project is using a extenal jar file which generated from a small project. I compiled the small project and import it to my project. The print command is still not working(it cannot print to the console). Don't know the cause. Anyway, I will do pop up the message by adding a message box dialog. Really thanks for your advices.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic