Running an applet as an application


[ 다음 글들 ] [ 이어서 글올리기(답하기) ] [ 자바 묻고 답하기 ]

글쓴이 :Sung Yi 2000년 2월 11일 01:33:01

In Reply to: 애플릿에서 애플리케이션을 동시에 사용한가요? posted by 이호연 on 2000년 2월 11일 01:03:42:

It is fairly simple.


Here is the story how it goes in a Java applet sequentially.


1. extends Applet
2. set frame
3. init();
3. start();


In Java application, stick above lines in the main() method.


Here is an example:


import java.applet.*;
import java.awt.*;


public class apple extends Applet{
Font font = new Font("Dialog", Font.BOLD, 20);
String str = "Applet/Application";


public void init() {
super.init();
}
public static void main(java.lang.String[] args) {
apple applet = new apple();
java.awt.Frame frame = new java.awt.Frame("Applet");


frame.add("Center", applet);
frame.setSize(350, 250);
frame.show();


applet.init();
applet.start();
}


public void paint(Graphics g) {
g.setFont(font);
g.setColor(Color.black);
g.drawString(str, 5, 50);
}
}


This program should run inside the browser or as a stand alone program.



다음 글들:



이어서 글올리기(답하기)

이름:
E-Mail:
제목:
내용:
HTML 태그 포함 여부: HTML 문서일 경우 체크
관련 URL(선택):
URL 제목(선택):
관련 이미지 URL:


[ 다음 글들 ] [ 이어서 글올리기(답하기) ] [ 자바 묻고 답하기 ]