ArticleDirectory
- 2. A problem when converting a common application into an applet
1 Java, Conditional compilation
Java does not have a Conditional compilation mechanism similar to C/C ++ Because Java considers itself cross-platform, the previous Conditional compilation was designed to solve the problem of C/C ++ quick platform. However, Conditional compilation and translation can also be used for debugging.
ProgramYou can introduce the assertion mechanism commonly used in C, that is, create an assertion class, and define an empty assertion class to put it in a different namespace.
CodeYou only need to import the package of the empty assertion class to the original program when you change the debugging version to the shipping version.
This technique can be used in any type of Conditional compilation program code.
Now 1. Version 4 seems to be able to use assert and assert mechanisms.
2. A problem when converting a common application into an applet
Basically, an application has a jframe as the outer frame. However, jframe cannot be added to the applet; otherwise, the prompt is: you cannot add a window to the applet (jframe extends window ).
Add jframe. getcontentpane () instead of directly adding jframe.