Skip to content

Instantly share code, notes, and snippets.

@shigemk2
Last active December 28, 2015 04:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shigemk2/7441528 to your computer and use it in GitHub Desktop.
Save shigemk2/7441528 to your computer and use it in GitHub Desktop.
やさしいJava 活用編 1
  • アプリケーションは単体で動作するプログラム
  • アプレットはwebブラウザなどの上で動作するプログラム
  • Javaを使って作成したテキスト形式のプログラムをソースコードという
  • ソースコードからコンパイルするとバイトコード形式のクラスファイルが得られる
  • インタプリタ(java)によって、アプリケーションを実行できる
  • アプレットビューアによってアプレットを実行できる
public class Sample1
{
public static void main(String[] args)
{
System.out.println("ようこそアプリケーションへ!");
}
}
<html>
<head>
<title>サンプル</title>
</head>
<body>
<applet code = "Sample2.class" width = 200 height = 200>
</applet>
</body>
</html>
import javax.swing.*;
public class Sample2 extends JApplet
{
private JLabel lb;
public void init()
{
lb = new JLabel();
lb.setText("ようこそアプレットへ!");
add(lb);
}
}
public class SampleP1
{
public static void main(String[] args)
{
System.out.println("こんにちは");
System.out.println("さようなら");
}
}
<html>
<head>
<title>サンプル</title>
</head>
<body>
<applet code = "Sample2.class" width = 300 height = 300>
</applet>
</body>
</html>
import javax.swing.*;
public class SampleP2 extends JApplet
{
private JLabel lb;
public void init()
{
lb = new JLabel();
lb.setText("ようこそアプレットへ!");
add(lb);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment