Kamis, 07 Januari 2010

Applet Dasar

Humm mau poring apllet nih
tp sory kalo cuma dasar banget
bisa aku masih cupu sih heheheheheh




 Applet selain dapat di tag di browser, applet juga dapat dieksekusi menggunakan appletviewer
nah source codenya dibawah ini yha




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

/**
 * This applet spices up "Hello World" with graphics, colors, and a font.
 **/
public class SecondApplet extends Applet {
  static final String message = "Hello World";
  private Font font;

  // One-time initialization for the applet
  // Note: no constructor defined.
  public void init() {
    font = new Font("Helvetica", Font.BOLD, 48);
  }

  // Draw the applet whenever necessary.  Do some fancy graphics.
  public void paint(Graphics g) {
    // The pink oval
    g.setColor(Color.BLUE);
    g.fillOval(10, 10, 330, 100);

    // The red outline. Java doesn't support wide lines, so we
    // try to simulate a 4-pixel wide line by drawing four ovals.
    g.setColor(Color.cyan);
    g.drawOval(10,10, 330, 100);
    g.drawOval(9, 9, 332, 102);
    g.drawOval(8, 8, 334, 104);
    g.drawOval(7, 7, 336, 106);

    // The text
    g.setColor(Color.black);
    g.setFont(font);
    g.drawString(message, 40, 75);
  }
}

1 komentar:

  1. waaaaa
    boleh ni gan
    bermanfaat bgt terutama bwt sy yg baru blj java
    jadi thx bgt ya
    owh iy kalo ada posting tentang java lagi tolong kirim juga ke e-mail agung.yudha007@gmail.com yah

    once again thx very much

    BalasHapus