File: HelloWeb.j

package info (click to toggle)
jasmin-sable 1.2-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, sarge
  • size: 1,464 kB
  • ctags: 1,903
  • sloc: java: 12,496; makefile: 126; csh: 93; sh: 93
file content (91 lines) | stat: -rw-r--r-- 2,136 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
; --- Copyright Jonathan Meyer 1996. All rights reserved. -----------------
; File:      jasmin/examples/HelloWeb.j
; Author:    Jonathan Meyer, 10 July 1996
; Purpose:   Demonstration of a Jasmin-created applet
; -------------------------------------------------------------------------
; HelloWeb.j

; This demonstrates how you can use Jasmin to create an applet.

; The code below is like the Java code:
;
;     import java.applet.*;
;     import java.awt.*;
;
;     public class HelloWeb extends Applet {
;        private Font font;
;
;        public void init() {
;            font = new Font("Helvetica", Font.BOLD, 48);
;        }
;
;        public void paint(Graphics g) {
;            g.setFont(font);
;            g.drawString("Hello World!", 25, 50);
;        }
;     }


.class public HelloWeb
.super java/applet/Applet

.field private font Ljava/awt/Font;


; my init() method - allocate a font and assign it to this.font.

.method public init()V
    .limit stack 5

    ; Create a new Font and call its constructor with
    ; "Helvetica", 1 (i.e. Font.BOLD), and 48.

    new java/awt/Font
    dup
    ldc "Helvetica"
    iconst_1
    bipush 48
    invokenonvirtual java/awt/Font/<init>(Ljava/lang/String;II)V

    ; now store the Font on the stack in this.font
    aload_0
    swap
    putfield HelloWeb/font Ljava/awt/Font;

    ; done
    return
.end method

; my paint() method - draws the string "Hello World!" using this.font.

.method public paint(Ljava/awt/Graphics;)V
    .limit stack 4
    .limit locals 2

    ; local variable 0 holds <this>
    ; local variable 1 holds the java.awt.Graphics instance ('g').

    ; g.setFont(this.font);
    aload_1
    aload_0
    getfield HelloWeb/font Ljava/awt/Font;
    invokevirtual java/awt/Graphics/setFont(Ljava/awt/Font;)V

    ; g.drawString("Hello Web!", 25, 50);
    aload_1
    ldc "Hello Web!"
    bipush 25
    bipush 50
    invokevirtual java/awt/Graphics/drawString(Ljava/lang/String;II)V

    ; done
    return
.end method


; standard constructor
.method public <init>()V
    aload_0
    invokenonvirtual java/applet/Applet/<init>()V
    return
.end method