Minggu, 15 Januari 2012

Our Prototype


import for make java desktop aplication.
import org.jdesktop.application.Action;
import org.jdesktop.application.Application;
import org.jdesktop.application.SingleFrameApplication;


 application main class .

public class FP_MatdisApp extends SingleFrameApplication {

   
code for draw frame in startup.
    
    @Override protected void startup() {
        show(new FP_MatdisView(this));
    }

    @Override protected void configureWindow (java.awt.Window root) {
    }
    public static FP_MatdisApp getApplication() {
        return Application.getInstance(FP_MatdisApp.class);
    }

Main class.
    public static void main(String[] args) {
        launch(FP_MatdisApp.class, args);
    }

Method for show  tips1.
    @Action
    public void showtips() {
        Tips1 a = new Tips1();
        a.Tips_1();
    }

Method for show menu “tips”
    @Action
    public void showmenu_tips() {
        Menu_Tips a = new Menu_Tips();
        a.MenuTips();
    }

Method to show the ilustration of “nyanyi” menu and “belajar” menu .
    @Action
    public void ilustrasi_nyanyi() {
        ilustrasi a = new ilustrasi ();
        a.ilustrasi();
    }
   
Method to show Option menu.
    @Action
    public void showoption() {
        Option a = new Option();
        a.Option();
    }
   
}

Class FP_MatdisView.java

main class for main menu frame
public class FP_MatdisView extends FrameView {
               
default frame code from netbeans.
    public FP_MatdisView(SingleFrameApplication app){...}

initialization of class ilustrasi.java
ilustrasi a = new ilustrasi ();

Command when “nyanyi” button is clicked.
private void nyanyiActionPerformed (java.awt.event.ActionEvent evt) {                                      
        a.ilustrasi();
}                                     

Command when “keluar” button is clicked.
private void keluarActionPerformed (java.awt.event.ActionEvent evt) {                                      
        System.exit(0);
}                                     



Class Gambar.java

import java.awt.Color;
import java.awt.Graphics;

public class Gambar {
   
method for draw two line.
    void garis (Graphics gbr){
        gbr.drawLine(20, 35, 495, 35);
        gbr.drawLine(20, 165, 495, 165);
    }
 
This method used to paint an ilustration not . this method is intergrated with “Gambar Not” button
    void paintNot(Graphics gbr){
       
drawrect used to draw a rectangle without fill.           
        for (int i=0; i<=2;i++)
        gbr.drawRect(50+(i*15), 135, 10, 10);
   
        for (int i=0; i<=1;i++)
        gbr.drawRect(110+(i*15), 85, 10, 10);
   
        for (int i=0; i<=3;i++)
        gbr.drawRect(155+(i*15), 105, 10, 10);
   
        for (int i=0; i<=2;i++)
        gbr.drawRect(230+(i*15), 85, 10, 10);
   
        for (int i=0; i<=3;i++)
        gbr.drawRect(290+(i*15), 65, 10, 10);
       
        for (int i=0; i<=4;i++)
        gbr.drawRect(365+(i*15), 105, 10, 10);
       
        for (int i=0; i<=1;i++)
        gbr.drawRect(455+(i*15), 135, 10, 10);
   
    }
   
Method for the ilustration while “mulai” button clicked
    void mainkan(Graphics gbr) throws InterruptedException{
   
setColor used to set rectangle color.
Fillrect used to draw filled rectangle.
Thread.sleep used to pause the thread for a while, according to specified time.
        for (int i=0; i<=2;i++){
            gbr.setColor(Color.green);
            gbr.fillRect(50+(i*15), 135, 10, 10);
            Thread.sleep(500);
        }
   
        for (int i=0; i<=1;i++){
            gbr.setColor(Color.red);
            gbr.fillRect(110+(i*15), 100, 10, 10);
            Thread.sleep(500);
        }
   
        for (int i=0; i<=1;i++){
            gbr.setColor(Color.yellow);
            gbr.fillRect(155+(i*15), 115, 10, 10);
            Thread.sleep(500);
        }
        for (int i=2; i<=3;i++){
            gbr.setColor(Color.green);
            gbr.fillRect(155+(i*15), 105, 10, 10);
            Thread.sleep(500);
        }
       
        for (int i=0; i<=2;i++){
            gbr.setColor(Color.red);
            gbr.fillRect(230+(i*15), 70, 10, 10);
            Thread.sleep(500);
        }
       
        for (int i=0; i<=3;i++){
            gbr.setColor(Color.green);
            gbr.fillRect(290+(i*15), 65, 10, 10);
            Thread.sleep(500);
        }
       
        for (int i=0; i<=1;i++){
            gbr.setColor(Color.red);
            gbr.fillRect(365+(i*15), 120, 10, 10);
            Thread.sleep(500);
        }
       
        for (int i=2; i<=2;i++){
            gbr.setColor(Color.yellow);
            gbr.fillRect(365+(i*15), 115, 10, 10);
            Thread.sleep(500);
        }
       
        for (int i=3; i<=4;i++){
            gbr.setColor(Color.green);
            gbr.fillRect(365+(i*15), 105, 10, 10);
            Thread.sleep(500);
        }
       
        for (int i=0; i<=1;i++){
            gbr.setColor(Color.green);
            gbr.fillRect(455+(i*15), 135, 10, 10);
            Thread.sleep(500);
        }
     }
}

Class Menu_Tips.java

This is method when pernafasan button is clicked,
Dispose() is used to close the menu_tips frame and run.Tips1() is code to open the Tips1 frame that contain information about “pernafasan”
private void pernafasanActionPerformed (java.awt.event.ActionEvent evt) {                                           
        dispose();
        Tips1 run = new Tips1();
        run.Tips_1();
    }                 
                       
This is method when artikulasi button is clicked,
Dispose() is used to close the menu_tips frame and run.Tips2() is code to open the Tips2 frame that contain information about “artikulasi”
 private void artikulasiActionPerformed(java.awt.event.ActionEvent evt) {                                          
            dispose();
            Tips2 run = new Tips2();
            run.Tips_2();
    }                                         
This is method to open MenuTips frame
    public void MenuTips(){
       Menu_Tips run = new Menu_Tips();
       run.setAlwaysOnTop(true);
       run.setVisible(true);
    }

Tidak ada komentar:

Posting Komentar