[Document Introduction] display text is the most basic function in Java. It is very simple to support text display.
Display text is the most basic function in Java. It supports text display in a very simple way. You only need to use the drawString () function in Graphics. Let's look at the simplest example of ghq:
// Ghq. java
Import java. awt .*;
Import java. applet .*;
Public class ghq extends Applet
{
String text = "ghq is a student! ";
Public void paint (Graphics g)
{
G. drawString (text, 20, 20 );
} // Display the text content at the coordinates of 20 and 20
}
This is the most basic Java Applet. Only "ghq is a student!" is displayed during running !". Java supports Unicode, so Chinese characters can be well displayed in Java !" Change to "Hello! Welcome to visit !", It can also be displayed. (If it cannot be correctly displayed, It is a browser Bug. For example, IE4.0 has such a problem. use Netscape or IE5.0 or later ). It is worth noting that in Java, each character is represented by 16 bits rather than 8 bits, which is different from the C language.