Java Applet Getting Started 13

zhaozj2021-02-11  178

Getting started with Java Applet

YY435

Pacific Network Academy

Third day

4. Sign

The label is that the user can only view, the text display area that cannot be modified, which can play a role of information, each label with a Label class object. Please see example:

example:

What is the above example uses Java? Its syntax is as follows:

... // is the same as the previous example! 1. Label Prompt1 = New Label ("This is the label 1!"); 2. Label Prompt2 = New Label ("This is the label 2!"); 3. Add (prompt1); 4. Add (prompt2); ...... // is the same as the previous example!

analysis:

Chapter 1: Call the function label to establish the first tag prompt1;

Chapter 2: Call the function label to establish the second tag pROMPT2;

Line 3: Add the label 1 to the container to make it displayed on the screen.

Chapter 4: Similarly, the label 2 is added to the container to enable it to display it on the screen.

The label cannot accept the user's input, so it is not possible to raise an event, not an event source. in case

Want to modify the text displayed on the label, you can use the method of the Label object GetText (new characters)

Strings), the same for an unknown label, can be called Label object GetText ()

Method to get its text content.

转载请注明原文地址:https://www.9cbs.com/read-4735.html

New Post(0)