Internet Programming with Java Course 1 Създаване на user interface с Java. Въведение в awt



Дата04.03.2016
өлшемі1.46 Mb.
#40784

Internet Programming with Java Course

2.1 Създаване на user interface с Java. Въведение в AWT.

2.2 Създаване на Java аплети – основни концепции

Applets

Hello World: The Applet


The reason people are excited about Java as more than just another OOP language is because it allows them to write interactive applets on the web. Hello World isn't a very interactive program, but let's look at a webbed version.

import java.applet.Applet;

import java.awt.Graphics;

public class HelloWorldApplet extends Applet {
public void paint(Graphics g) {

g.drawString("Hello world!", 50, 25);

}

}

The applet version of HelloWorld is a little more complicated than the HelloWorld application, and it will take a little more effort to run it as well.



First type in the source code and save it into file called HelloWorldApplet.java. Compile this file in the usual way. If all is well a file called HelloWorldApplet.class will be created. Now you need to create an HTML file that will include your applet. The following simple HTML file will do.





<a href="/ekskursii-ferrari-world-abu-dhabi.html">Hello World </a>


This is the applet:








Достарыңызбен бөлісу:




©dereksiz.org 2024
әкімшілігінің қараңыз

    Басты бет