Kyfi's Blog

jawaban v-class

Posted on: April 4, 2012

jawaban no 1:

 *      Hello.java
 */
import java.applet.Applet;
import java.awt.Graphics;

public class Hello extends Applet{
    public void paint(Graphics g){
        g.drawString(“Hello world!”, 100, 100);
    }
}
jawaban no 2:

import java.applet1.*;
import java.awt.*;

public class  CircleLuas extends Applet{
        public void paint(Graphics g){
            int lebar=100;
            int panjang=200;
            int frame;
            
            for (int a = 0 ; a<200 ; a = a + 5)
            {
                //g.drawLine(50,0,50,200);
                g.drawLine(a,0,a,100);
            }    
                  
        }
}

jawaban no 3:

CircleLine2.java
 */
import java.applet2.*;
import java.hitungluas.*;
import java.awt.event.*;
import java.lang.Math;

public class  CircleLuas extends Applet{
    
    int lebar;
    int tinggi;
    
    public void init() {
    
        lebar = getSize().width;
        tinggi = getSize().height;
    }
    
    
    public void paint(Graphics g){
            
        for (int a = 0 ; a<lebar ; a = a + 5)
        {
            //g.drawLine(50,0,50,200);
            g.drawLine(a,0,a,tinggi);
        }    
                  
    }
}

jawaban no 4:

/*
 *      Simple.java
import java.applet.Applet;
import java.awt.Graphics;

public class Simple extends Applet {

    StringBuffer buffer;

    public void init() {
    buffer = new StringBuffer();
        addItem(“initializing… “);
    }

    public void start() {
        addItem(“starting… “);
    }

    public void stop() {
        addItem(“stopping… “);
    }
    public void destroy() {
        addItem(“preparing for unloading…”);
    }

    void addItem(String newWord) {
    System.out.println(newWord);
        buffer.append(newWord);
        repaint();
    }

    public void paint(Graphics g) {
    //Draw a Rectangle around the applet’s display area.
        g.drawRect(0, 0, size().width – 1, size().height – 1);

    //Draw the current string inside the rectangle.
        g.drawString(buffer.toString(), 5, 15);
    }
}

jawaban no 5:

/*
 *      UpDate.java

 */

import java.applet.Applet;
import java.awt.Graphics;

public class CountUpdate extends Applet {
    int j=0;
    StringBuffer buffer;

    public void init() {
    buffer = new StringBuffer();
    tambah(“belum ada update, jumlah : “,(j++));
    tambah(”   ,initializing…… jumlah update : “,(j++));
    }
    
    public void start() {
        tambah(”   ,mulai… jumlah update : “,(j++));
    }
    public void stop() {
        tambah(“berhenti… “,j);
    }

    public void destroy() {
        tambah(“persiapan untuk unloading…”,j);
    }

    void tambah(String kata, int j) {
        System.out.println(kata+j);
        buffer.append(kata+j);
        repaint();
        j++;
    }
    public void paint(Graphics g) {
       g.drawRect(0, 0, size().width – 1, size().height – 1);
       g.drawString(buffer.toString(), 10, 20);
    }
}

 

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: