(Java)Penjumlahan Dengan Zkoss Framework

1. Create new Project – Java web – dan beri nam project terserah anda …

2. Buka File pada web pages – WEB-INF – index.zul dan tulis kan scrip di bawah ini :

<zk xmlns="http://www.zkoss.org/2005/zul">
    <window apply="Source.Jumlah" title="Penjumlahan" border="normal" mode="overlapped">

               <textbox id="angka1" focus="true" > </textbox> 
               <label value="+" > </label>
               <textbox id="angka2" focus="false" > </textbox> 

              <vbox> 

                <button width="325px " id="hasil" label="Hasil" > </button>
              </vbox>
                <vbox>

                <textbox width="320px" id="tampil" > </textbox>
                </vbox>
    </window>
</zk>

3. Create Class pada Source packages dan tuliskan scrip dibawah ini

import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.util.GenericForwardComposer;
import org.zkoss.zul.Textbox;

/**
 *
 * @author aerdy
 */
public class Jumlah extends GenericForwardComposer {
    private Textbox angka1;
    private Textbox angka2;
    private Textbox tampil;
    Float hasil;

    public void onClick$hasil(Event event){
        Float angka11 = Float.parseFloat(angka1.getText());
        Float angka22 = Float.parseFloat(angka2.getText());        
        hasil = angka11 + angka22;
        tampil.setText(""+hasil);
    }
}

<pre>

Hasil

Referensi : zkoss project

Advertisements

Published by

jarcode

hello I am jarcode

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s