cordova + ionic framework + mysql, crud operation on Android or iOS

tampilan di zenfone 4

Pernahkah agan melihat gambar dibawah ini di tv2 atau iklan2 yang menyertakan aplikasi seperti halnya traveloka ?

yupp, jika pernah melihat,,, aplikasi tersebut dibuat dengan cordova , istilah org bulenya adalah Hybrid Applications. yaitu aplikasi yang bisa berjalan di 2 platform yang berbeda dan akan terlihat sama. dan kebetulan saya akan memberi tutor simple . . :).
membuat aplikasi ini tidaklah sulit, karena ionic memberikan kemudahan dalam membuat apps ini. apalagi yang suka ngoprek2 angularJS+HTML5 seperti halnya ane. . hehee, pasti tidak akan sulit untuk membuatnya. 

syarat :
  • install JDK 8 
  • install cordova
  • install ionic
  • install node.js
setelah semuanya terinstall maka buat project baru. buka CMD di window, atau terminal kalo di linux. ketik perintah :
  • ionic start namaApp blank
  • cd namaApp
  • ionic platform add android //untuk android
  • ionic platform add ios //untuk ios, ini memerlukan xcode dan ios sdk, intinya harus menggunakan mac not windows. hee
  • ionic serve //maka akan berjalan di web browser
Tampilan Di Chrome
ionic berjalan di localhost:8100, ini akan mempercepat pengerjaan membuat aplikasi dibanding kita menggunakan emulator android atau AVD. 
so,,, AVD di laptop saya selalu not respon dan tidak bisa berjalan sama sekali, maklum laptop ane cuma AMD A6 atau standart dual core saja. jadi membuat aplikasi tanpa AVD melainkan pake chrome yang kemudian dijadikan file .APK dan kemudian berjalan di my asus zenfone.

silahkan edit di folder www dalam projectnya. disitu ada index.html, app.js dan file2 java. untuk IDE bisa pake notepad++ dan netbeans, atau bisa pake editor lainnya tergantung selera. jika ane notepad++ dan netbeans. hee

--Penjelasan tentang AngularJS pada ionic.

1) app.js
ini saya gunakan untuk membuat route, ibarat kita ingin ke pasar untuk beli bakwan rute mana yang akan kita gunakan. kurang lebih seperti itu. 

2) service.js
ini saya gunakan untuk layanan berbasis http yang kemudian akan dilanjutkan ke controller, dalam project, saya menggunakan PHP dan mysql untuk mencetak json yang kemudian akan di parsing di service,js

3) controller.js
ini saya gunakan sebagai controller template.

--Simple Crud By Rudy

database dan script php saya taruh di idhostinger karena gretong... bisa di akses di http://herudi-sahimar.16mb.com/select.php itu untuk menampilkan data.

Server Idhostinger


1) Friend list
menampilkan dari database ke list.



2) Add Friend
menambahkan data teman.





3) Friend Detail
melihat detail teman, dalam hal ini menggunakan select where id = blablabla.


4) Edit Friend
update data teman.


5) Delete Friend
hapus teman tinggal tekan button merah di kiri. hapus where id = blablabla



Live On My Zenfone 4





silahkan download source code simpleCrud.rar

my apk file silahkan download simpleCrud.apk 


run javafx in web browser



Dear sobat berbahagia,
kali ini ane akan barbagi ilmu tentang bagaimana menjalankan aplikasi javafx di web browser ?
sebenarnya javafx tidak usah menconfigurasi dan membuat file .jnlp lagi, karena ketika project di build maka di folder dist juga mengcreate 3 file yaitu .jar, .jnlp dan .html.

silahkan upload di locahost atau di webhosting masing2. hehee simple yah

dan ini jika di run file jar nya



oke cukup sekian dan terimakasih.


webview javafx featuring html5 dan web service




selamat siang sobat blogger, masih tidak bosan kan memperdalam javafx applications. . 
kali ini saya akan berbagi sedikit ilmu di webview javafx. sebelumnya apa itu webview di javafx? lantas bagaimana cara kerjanya.? menurut saya simple aja, webview merupakan layout atau node untuk menampilkan isi web.  

perlu diketahui aplikasi ini hanya sample. jadi kalo kurang berkenan mohon maaf kakak. :D
ane membuat aplikasi ini dengan waktu 10 menit saja. bagaimana bisa ? karena saya mendapat tutorial dari org lain . . hee



mengcreate 3 project  



jangan lupa install glassfish 4 ya.



project menggunakan java DB (sudah tersedia di netbeans tinggal buat database baru)



test maximize and restore stage javafx



terimakasih . . . 

Spring 4, Hibernate 4 on JavaFX

Selamat Malam agan dan aganwati sekalian yg semakin lama semakin ganteng dan catik. .:D
Kali ini ane mencoba memberi tutorial tentang bagaimana integrasi sebuah framework terhadap Javafx, adalah Spring xml config versi 4 dan hibernate versi 4. Kita tahu bahwa hibernate adalah framework java yg paling familiar dan pastinya paling mudah dipelajari, framework ini berbasis ORM (Object Relational Mapping). 

Berhubung ane sangat suka sekali bola, maka untuk percobaan aplikasinya berhubungan dengan sepak bola, tapi ga papa walau bertema sepak bola agan dan aganwati bisa mengimplemet nya ke system apa aja. yang paling penting adalah konsep dan algoritmanya bener.

Syarat Umum: 
  • Netbeans //yang Terbaru, masa masih pake yang lama.:D
  • Java //yang terbaru kalo bisa.
  • Scene Builder 2
  • Teman saat ngoding. rokok, kopi, gorengan, cewek cakep biar semangat ya. :D. kalo    aganwati cukup ditemeni boneka hello kity aja kali ya. :(
Library yang dibutuhkan: 
  • Hibernate 4.x.x (default Netbeans 8.1)
  • Spring Framework 4.0.1 (default Netbeans 8.1)
  • MySql Connector (default Netbeans 8.1)
  • fontawesomefx-8.0.8.jar (download)
  • openjfx-dialogs-1.0.2.jar (download)
  • aopalliance-1.0.jar (download)
  • Silahkan ke 3 library Disini

  • List Player's 

  • List Player's 2

  • List Club's


menurut ane kurang asyik rasanya bila bermain hibernate tanpa adanya relasi table.

pada gambar diatas table club dan player saling berelasi atau berhubungan dan sebagai penyambungnya atau column referensinya adalah idClub. tetapi yang akan di tampilkan di tableview javafx adalah nama clubnya bukan id club.
Oke Langsung Pada intinya:
  • Buat Database listplayers
  • 1
    CREATE DATABASE `listplayers` /*!40100 COLLATE 'latin1_swedish_ci' */;
    CREATE DATABASE `listplayers` /*!40100 COLLATE 'latin1_swedish_ci' */;
    
  • Buat table club
  • 1
    2
    3
    4
    5
    6
    7
    CREATE TABLE `club` (
        `idClub` CHAR(5) NOT NULL,
        `namaClub` VARCHAR(50) NULL DEFAULT NULL,
        PRIMARY KEY (`idClub`)
    )
    COLLATE='latin1_swedish_ci'
    ENGINE=InnoDB;
    CREATE TABLE `club` (
        `idClub` CHAR(5) NOT NULL,
        `namaClub` VARCHAR(50) NULL DEFAULT NULL,
        PRIMARY KEY (`idClub`)
    )
    COLLATE='latin1_swedish_ci'
    ENGINE=InnoDB;
    
  • Buat table player
  • 01
    02
    03
    04
    05
    06
    07
    08
    09
    10
    CREATE TABLE `player` (
        `idPemain` CHAR(5) NOT NULL,
        `namaPemain` VARCHAR(50) NULL DEFAULT NULL,
        `idClub` CHAR(5) NULL DEFAULT NULL,
        PRIMARY KEY (`idPemain`),
        INDEX `FK_namapemain_listclub` (`idClub`),
        CONSTRAINT `FK_namapemain_listclub` FOREIGN KEY (`idClub`) REFERENCES `club` (`idClub`) ON UPDATE CASCADE ON DELETE CASCADE
    )
    COLLATE='latin1_swedish_ci'
    ENGINE=InnoDB;
    CREATE TABLE `player` (
        `idPemain` CHAR(5) NOT NULL,
        `namaPemain` VARCHAR(50) NULL DEFAULT NULL,
        `idClub` CHAR(5) NULL DEFAULT NULL,
        PRIMARY KEY (`idPemain`),
        INDEX `FK_namapemain_listclub` (`idClub`),
        CONSTRAINT `FK_namapemain_listclub` FOREIGN KEY (`idClub`) REFERENCES `club` (`idClub`) ON UPDATE CASCADE ON DELETE CASCADE
    )
    COLLATE='latin1_swedish_ci'
    ENGINE=InnoDB;
    


  • Selanjutnya Buat project baru di netbeans, Javafx>>Javafx FXML Application. selanjutnya tinggal next next aja.

  • Selanjutnya buat beberapa package,  kalo ane sukanya seperti dibawah ini. terlihat hanya mainClass aja yang di sisakan.

  • Selanjutnya buat hibernate configuration wizard 
01

  • berikan nama. kalau ane dari sananya saja namanya.
02

  •  buat connection baru.
03

  •  pilih driver MYSQL bila databasenya mysql.
04
  • isi sesuai dengan setting database mysql yg agan punya.
05

  • source hibernate.cfg.xml //tapi akhirnya koneksi saya hapus. . :D karena pake Spring. 
  • 1
    2
    3
    4
    5
    6
    7
    8
    9
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
    <hibernate-configuration>
      <session-factory>
        <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
        <mapping resource="listplayer/model/Club.hbm.xml"/>
        <mapping resource="listplayer/model/Player.hbm.xml"/>
      </session-factory>
    </hibernate-configuration>
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
    <hibernate-configuration>
      <session-factory>
        <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
        <mapping resource="listplayer/model/Club.hbm.xml"/>
        <mapping resource="listplayer/model/Player.hbm.xml"/>
      </session-factory>
    </hibernate-configuration>
    


  • sekarang buat hibernate.reverse enginering nya.
01
  • beri nama, kalau ane default saja namanya.
02
  • add semua table yang ada bila dibutuhkan.
  • source hibernate.reveng.xml
  • 1
    2
    3
    4
    5
    6
    7
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE hibernate-reverse-engineering PUBLIC "-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd">
    <hibernate-reverse-engineering>
      <schema-selection match-catalog="listplayers"/>
      <table-filter match-name="club"/>
      <table-filter match-name="player"/>
    </hibernate-reverse-engineering>
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE hibernate-reverse-engineering PUBLIC "-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd">
    <hibernate-reverse-engineering>
      <schema-selection match-catalog="listplayers"/>
      <table-filter match-name="club"/>
      <table-filter match-name="player"/>
    </hibernate-reverse-engineering>
    

  • Buat Model yang generate dari database. dengan cara dibawah ini. yang perlu diingat ditaruh di package listplayer.model

  • karena ane menggunakan .hbm.xml maka yang ane centang ya ini.
  • Package listplayer.model source Club.hbm.xml
  • 01
    02
    03
    04
    05
    06
    07
    08
    09
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    <?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    <!-- Generated Nov 27, 2014 7:20:44 AM by Hibernate Tools 4.3.1 -->
    <hibernate-mapping>
        <class name="listplayer.model.Club" table="club" catalog="listplayers" optimistic-lock="version">
            <id name="idClub" type="string">
                <column name="idClub" length="5" />
                <generator class="assigned" />
            </id>
            <property name="namaClub" type="string">
                <column name="namaClub" length="50" />
            </property>
            <set name="players" table="player" inverse="true" lazy="true" fetch="select">
                <key>
                    <column name="idClub" length="5" />
                </key>
                <one-to-many class="listplayer.model.Player" />
            </set>
        </class>
    </hibernate-mapping>
    <?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
    <!-- Generated Nov 27, 2014 7:20:44 AM by Hibernate Tools 4.3.1 -->
    <hibernate-mapping>
        <class name="listplayer.model.Club" table="club" catalog="listplayers" optimistic-lock="version">
            <id name="idClub" type="string">
                <column name="idClub" length="5" />
                <generator class="assigned" />
            </id>
            <property name="namaClub" type="string">
                <column name="namaClub" length="50" />
            </property>
            <set name="players" table="player" inverse="true" lazy="true" fetch="select">
                <key>
                    <column name="idClub" length="5" />
                </key>
                <one-to-many class="listplayer.model.Player" />
            </set>
        </class>
    </hibernate-mapping>
    
  • Package listplayer.model nama class Club.java
  • 01
    02
    03
    04
    05
    06
    07
    08
    09
    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
    package listplayer.model;
    // Generated Nov 27, 2014 7:20:43 AM by Hibernate Tools 4.3.1
     
     
    import java.util.HashSet;
    import java.util.Set;
     
    /**
     * Club generated by hbm2java
     */
    public class Club  implements java.io.Serializable {
     
     
        private String idClub;
        private String namaClub;
        private Set players = new HashSet(0);
     
        public Club() {
        }
     
         
        public Club(String idClub) {
            this.idClub = idClub;
        }
        public Club(String idClub, String namaClub, Set players) {
           this.idClub = idClub;
           this.namaClub = namaClub;
           this.players = players;
        }
        
        public String getIdClub() {
            return this.idClub;
        }
         
        public void setIdClub(String idClub) {
            this.idClub = idClub;
        }
        public String getNamaClub() {
            return this.namaClub;
        }
         
        public void setNamaClub(String namaClub) {
            this.namaClub = namaClub;
        }
        public Set getPlayers() {
            return this.players;
        }
         
        public void setPlayers(Set players) {
            this.players = players;
        }
     
     
    }
    package listplayer.model;
    // Generated Nov 27, 2014 7:20:43 AM by Hibernate Tools 4.3.1
    
    
    import java.util.HashSet;
    import java.util.Set;
    
    /**
     * Club generated by hbm2java
     */
    public class Club  implements java.io.Serializable {
    
    
        private String idClub;
        private String namaClub;
        private Set players = new HashSet(0);
    
        public Club() {
        }
    
        
        public Club(String idClub) {
            this.idClub = idClub;
        }
        public Club(String idClub, String namaClub, Set players) {
           this.idClub = idClub;
           this.namaClub = namaClub;
           this.players = players;
        }
       
        public String getIdClub() {
            return this.idClub;
        }
        
        public void setIdClub(String idClub) {
            this.idClub = idClub;
        }
        public String getNamaClub() {
            return this.namaClub;
        }
        
        public void setNamaClub(String namaClub) {
            this.namaClub = namaClub;
        }
        public Set getPlayers() {
            return this.players;
        }
        
        public void setPlayers(Set players) {
            this.players = players;
        }
    
    
    }
    
  • Package listplayer.model source Player.hbm.xml
  • 01
    02
    03
    04
    05
    06
    07
    08
    09
    10
    11
    12
    13
    14
    15
    16
    17
    18
    <?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    <!-- Generated Nov 27, 2014 7:20:44 AM by Hibernate Tools 4.3.1 -->
    <hibernate-mapping>
        <class name="listplayer.model.Player" table="player" catalog="listplayers" optimistic-lock="version">
            <id name="idPemain" type="string">
                <column name="idPemain" length="5" />
                <generator class="assigned" />
            </id>
            <many-to-one name="club" class="listplayer.model.Club" fetch="select">
                <column name="idClub" length="5" />
            </many-to-one>
            <property name="namaPemain" type="string">
                <column name="namaPemain" length="50" />
            </property>
        </class>
    </hibernate-mapping>
    <?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
    <!-- Generated Nov 27, 2014 7:20:44 AM by Hibernate Tools 4.3.1 -->
    <hibernate-mapping>
        <class name="listplayer.model.Player" table="player" catalog="listplayers" optimistic-lock="version">
            <id name="idPemain" type="string">
                <column name="idPemain" length="5" />
                <generator class="assigned" />
            </id>
            <many-to-one name="club" class="listplayer.model.Club" fetch="select">
                <column name="idClub" length="5" />
            </many-to-one>
            <property name="namaPemain" type="string">
                <column name="namaPemain" length="50" />
            </property>
        </class>
    </hibernate-mapping>
    
  • Package listplayer.model nama class Player.java
  • 01
    02
    03
    04
    05
    06
    07
    08
    09
    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
    package listplayer.model;
    // Generated Nov 27, 2014 7:20:43 AM by Hibernate Tools 4.3.1
     
     
     
    /**
     * Player generated by hbm2java
     */
    public class Player  implements java.io.Serializable {
     
     
        private String idPemain;
        private Club club;
        private String namaPemain;
        //view one to many
        private String strNamaClub;
     
        public Player() {
        }
     
         
        public Player(String idPemain) {
            this.idPemain = idPemain;
        }
        public Player(String idPemain, Club club, String namaPemain) {
           this.idPemain = idPemain;
           this.club = club;
           this.namaPemain = namaPemain;
        }
        
        public String getIdPemain() {
            return this.idPemain;
        }
         
        public void setIdPemain(String idPemain) {
            this.idPemain = idPemain;
        }
        public Club getClub() {
            return this.club;
        }
         
        public void setClub(Club club) {
            this.club = club;
        }
        public String getNamaPemain() {
            return this.namaPemain;
        }
         
        public void setNamaPemain(String namaPemain) {
            this.namaPemain = namaPemain;
        }
     
        //model one to many
     
        public String getStrNamaClub() {
            strNamaClub = club.getNamaClub();
            return strNamaClub;
        }
     
        public void setStrNamaClub(String strNamaClub) {
            this.strNamaClub = strNamaClub;
        }
         
     
    }
    package listplayer.model;
    // Generated Nov 27, 2014 7:20:43 AM by Hibernate Tools 4.3.1
    
    
    
    /**
     * Player generated by hbm2java
     */
    public class Player  implements java.io.Serializable {
    
    
        private String idPemain;
        private Club club;
        private String namaPemain;
        //view one to many
        private String strNamaClub;
    
        public Player() {
        }
    
        
        public Player(String idPemain) {
            this.idPemain = idPemain;
        }
        public Player(String idPemain, Club club, String namaPemain) {
           this.idPemain = idPemain;
           this.club = club;
           this.namaPemain = namaPemain;
        }
       
        public String getIdPemain() {
            return this.idPemain;
        }
        
        public void setIdPemain(String idPemain) {
            this.idPemain = idPemain;
        }
        public Club getClub() {
            return this.club;
        }
        
        public void setClub(Club club) {
            this.club = club;
        }
        public String getNamaPemain() {
            return this.namaPemain;
        }
        
        public void setNamaPemain(String namaPemain) {
            this.namaPemain = namaPemain;
        }
    
        //model one to many
    
        public String getStrNamaClub() {
            strNamaClub = club.getNamaClub();
            return strNamaClub;
        }
    
        public void setStrNamaClub(String strNamaClub) {
            this.strNamaClub = strNamaClub;
        }
        
    
    }
    
  • Langkah selanjutnya adalah membuat Spring XML Config.


  • Silahkan klik add spring framework, library nya sudah disediakan di netbenas.
  • jangan lupa beri nama. 


  • Beri nama Sesuai kebutuhan. kalo ane cukup ketik jdbc aja. :D


  •  source jdbc.properties
  • 1
    2
    3
    4
    5
    #Thu Nov 27 07:15:44 ICT 2014
    jdbc.url=jdbc\:mysql\://localhost\:3306/listplayers
    jdbc.username=root
    jdbc.driver=com.mysql.jdbc.Driver
    jdbc.password=herudi
    #Thu Nov 27 07:15:44 ICT 2014
    jdbc.url=jdbc\:mysql\://localhost\:3306/listplayers
    jdbc.username=root
    jdbc.driver=com.mysql.jdbc.Driver
    jdbc.password=herudi
    

  • Langkah selanjutnya buat config session dulu, ini berguna agar penulisan code nantinya lebih sederhana dan pendek.
  • Package listplayer.implement nama class configSession.java
  • 01
    02
    03
    04
    05
    06
    07
    08
    09
    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
    /*
     * To change this license header, choose License Headers in Project Properties.
     * To change this template file, choose Tools | Templates
     * and open the template in the editor.
     */
     
    package listplayer.implement;
     
    import org.hibernate.HibernateException;
    import org.hibernate.Session;
    import org.hibernate.SessionFactory;
    import org.hibernate.Transaction;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Repository;
     
    @Repository
    public class configSession {
        @Autowired
        SessionFactory sf;
     
        public SessionFactory getSf() {
            return sf;
        }
         
        public void setSf(SessionFactory sf) {
            this.sf = sf;
        }
         
        //insert data
        public void create(Object o) {
            Session session = this.sf.openSession();
            Transaction tx = session.beginTransaction();
            try {
               session.persist(o);
            } catch (HibernateException e) {
               System.out.println("Gagal Create");
            }
            tx.commit();
            session.close();
        }
         
        //update data
        public void update(Object o) {
            Session session = this.sf.openSession();
            Transaction tx = session.beginTransaction();
            try {
                session.merge(o);
            } catch (HibernateException e) {
                System.out.println("Gagal Update");
            }
            tx.commit();
            session.close();
        }
         
        //delete data
        public void delete(Object o) {
            Session session = this.sf.openSession();
            Transaction tx = session.beginTransaction();
            try {
                session.delete(o);
            } catch (HibernateException e) {
                System.out.println("Gagal Delete");
            }
            tx.commit();
            session.close();
        }
         
    }
    /*
     * To change this license header, choose License Headers in Project Properties.
     * To change this template file, choose Tools | Templates
     * and open the template in the editor.
     */
    
    package listplayer.implement;
    
    import org.hibernate.HibernateException;
    import org.hibernate.Session;
    import org.hibernate.SessionFactory;
    import org.hibernate.Transaction;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Repository;
    
    @Repository
    public class configSession {
        @Autowired
        SessionFactory sf;
    
        public SessionFactory getSf() {
            return sf;
        }
        
        public void setSf(SessionFactory sf) {
            this.sf = sf;
        }
        
        //insert data 
        public void create(Object o) {
            Session session = this.sf.openSession();
            Transaction tx = session.beginTransaction();
            try {
               session.persist(o);
            } catch (HibernateException e) {
               System.out.println("Gagal Create"); 
            }
            tx.commit();
            session.close();
        }
        
        //update data
        public void update(Object o) {
            Session session = this.sf.openSession();
            Transaction tx = session.beginTransaction();
            try {
                session.merge(o);
            } catch (HibernateException e) {
                System.out.println("Gagal Update"); 
            }
            tx.commit();
            session.close();
        }
        
        //delete data
        public void delete(Object o) {
            Session session = this.sf.openSession();
            Transaction tx = session.beginTransaction();
            try {
                session.delete(o);
            } catch (HibernateException e) {
                System.out.println("Gagal Delete"); 
            }
            tx.commit();
            session.close();
        }
        
    }
    
  • Package listplayer.interfaces  nama class interClub.java
  • 01
    02
    03
    04
    05
    06
    07
    08
    09
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    /*
     * To change this license header, choose License Headers in Project Properties.
     * To change this template file, choose Tools | Templates
     * and open the template in the editor.
     */
    package listplayer.interfaces;
     
    import java.util.List;
    import listplayer.model.Club;
     
    /**
     *
     * @author herudi-pc
     */
    public interface interClub {
        void saveOrUpdate(Club p);
        void delete(Club p);
        void autoId(Club p);
        List<Club> getAll();
        List<Club> search(String a);
    }
    /*
     * To change this license header, choose License Headers in Project Properties.
     * To change this template file, choose Tools | Templates
     * and open the template in the editor.
     */
    package listplayer.interfaces;
    
    import java.util.List;
    import listplayer.model.Club;
    
    /**
     *
     * @author herudi-pc
     */
    public interface interClub {
        void saveOrUpdate(Club p);
        void delete(Club p);
        void autoId(Club p);
        List<Club> getAll();
        List<Club> search(String a);
    }
    
  • Package listplayer.interfaces nama class interPlayer.java
  • 01
    02
    03
    04
    05
    06
    07
    08
    09
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    /*
     * To change this license header, choose License Headers in Project Properties.
     * To change this template file, choose Tools | Templates
     * and open the template in the editor.
     */
    package listplayer.interfaces;
     
    import java.util.List;
    import listplayer.model.Player;
     
    /**
     *
     * @author herudi-pc
     */
    public interface interPlayer {
        void saveOrUpdate(Player p);
        void delete(Player p);
        void autoId(Player p);
        List<Player> getAll();
        List<Player> search(String a);
    }
    /*
     * To change this license header, choose License Headers in Project Properties.
     * To change this template file, choose Tools | Templates
     * and open the template in the editor.
     */
    package listplayer.interfaces;
    
    import java.util.List;
    import listplayer.model.Player;
    
    /**
     *
     * @author herudi-pc
     */
    public interface interPlayer {
        void saveOrUpdate(Player p);
        void delete(Player p);
        void autoId(Player p);
        List<Player> getAll();
        List<Player> search(String a);
    }
    
  • Package listplayer.implement nama class implClub.java
  • 01
    02
    03
    04
    05
    06
    07
    08
    09
    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
    /*
     * To change this license header, choose License Headers in Project Properties.
     * To change this template file, choose Tools | Templates
     * and open the template in the editor.
     */
    package listplayer.implement;
     
    import java.util.List;
    import listplayer.interfaces.interClub;
    import listplayer.model.Club;
    import org.hibernate.Criteria;
    import org.hibernate.HibernateException;
    import org.hibernate.criterion.MatchMode;
    import org.hibernate.criterion.Projections;
    import org.hibernate.criterion.Restrictions;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Repository;
     
    @Repository
    public class implClub implements interClub {
        @Autowired
        configSession cs;
     
        @Override //menyimpan dan update Data
        public void saveOrUpdate(Club p) {
            if (p.getIdClub()==null) {
                cs.create(p);
            }else{
                cs.update(p);
            }
        }
     
        @Override //delete Data
        public void delete(Club p) {
            cs.delete(p);
        }
     
        @Override //auto ID
        public void autoId(Club p) {
            try {
                Criteria cr = cs.getSf().openSession().createCriteria(Club.class);
                cr.setProjection(Projections.max("idClub"));
                Object o = cr.uniqueResult();
                String auto = ""+(Integer.parseInt(o.toString().substring(2))+1);
                String nol = "";
                if (auto.length()==1){
                    nol = "00";
                } else if (auto.length()==2){
                    nol = "0";
                }else if (auto.length()==3){
                    nol = "";
                }   
                p.setIdClub("C."+nol+auto);
            } catch (NumberFormatException | HibernateException e) {
            }
        }
     
        @Override //menampilkan Data
        public List<Club> getAll() {
            return cs.getSf().openSession().createCriteria(Club.class).list();
        }
     
        @Override //mencari Data
        public List<Club> search(String a) {
            Criteria cr = cs.getSf().openSession().createCriteria(Club.class);
            cr.add(Restrictions.like("namaClub", a, MatchMode.ANYWHERE));
            return cr.list();
        }
         
    }
    /*
     * To change this license header, choose License Headers in Project Properties.
     * To change this template file, choose Tools | Templates
     * and open the template in the editor.
     */
    package listplayer.implement;
    
    import java.util.List;
    import listplayer.interfaces.interClub;
    import listplayer.model.Club;
    import org.hibernate.Criteria;
    import org.hibernate.HibernateException;
    import org.hibernate.criterion.MatchMode;
    import org.hibernate.criterion.Projections;
    import org.hibernate.criterion.Restrictions;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Repository;
    
    @Repository
    public class implClub implements interClub {
        @Autowired
        configSession cs;
    
        @Override //menyimpan dan update Data
        public void saveOrUpdate(Club p) {
            if (p.getIdClub()==null) {
                cs.create(p);
            }else{
                cs.update(p);
            }
        }
    
        @Override //delete Data
        public void delete(Club p) {
            cs.delete(p);
        }
    
        @Override //auto ID 
        public void autoId(Club p) {
            try {
                Criteria cr = cs.getSf().openSession().createCriteria(Club.class);
                cr.setProjection(Projections.max("idClub"));
                Object o = cr.uniqueResult();
                String auto = ""+(Integer.parseInt(o.toString().substring(2))+1);
                String nol = "";
                if (auto.length()==1){
                    nol = "00";
                } else if (auto.length()==2){
                    nol = "0";
                }else if (auto.length()==3){
                    nol = "";
                }    
                p.setIdClub("C."+nol+auto);
            } catch (NumberFormatException | HibernateException e) {
            }
        }
    
        @Override //menampilkan Data
        public List<Club> getAll() {
            return cs.getSf().openSession().createCriteria(Club.class).list();
        }
    
        @Override //mencari Data
        public List<Club> search(String a) {
            Criteria cr = cs.getSf().openSession().createCriteria(Club.class);
            cr.add(Restrictions.like("namaClub", a, MatchMode.ANYWHERE));
            return cr.list();
        }
        
    }
    
  • Package listplayer.implement nama class implPlayer.java 
  • 01
    02
    03
    04
    05
    06
    07
    08
    09
    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
    /*
     * To change this license header, choose License Headers in Project Properties.
     * To change this template file, choose Tools | Templates
     * and open the template in the editor.
     */
    package listplayer.implement;
     
    import java.util.List;
    import listplayer.interfaces.interPlayer;
    import listplayer.model.Player;
    import org.hibernate.Criteria;
    import org.hibernate.HibernateException;
    import org.hibernate.criterion.MatchMode;
    import org.hibernate.criterion.Projections;
    import org.hibernate.criterion.Restrictions;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Repository;
     
    @Repository
    public class implPlayer implements interPlayer {
        @Autowired
        configSession cs;
     
        @Override //save dan update data
        public void saveOrUpdate(Player p) {
            if (p.getIdPemain()==null) {
                cs.create(p);
            }else{
                cs.update(p);
            }
        }
     
        @Override //delete data
        public void delete(Player p) {
            cs.delete(p);
        }
     
        @Override //auto id
        public void autoId(Player p) {
            try {
                Criteria cr = cs.getSf().openSession().createCriteria(Player.class);
                cr.setProjection(Projections.max("idPemain"));
                Object o = cr.uniqueResult();
                String auto = ""+(Integer.parseInt(o.toString().substring(2))+1);
                String nol = "";
                if (auto.length()==1){
                    nol = "00";
                } else if (auto.length()==2){
                    nol = "0";
                }else if (auto.length()==3){
                    nol = "";
                }   
                p.setIdPemain("P."+nol+auto);
            } catch (NumberFormatException | HibernateException e) {
            }
        }
     
        @Override //menampilkan data
        public List<Player> getAll() {
            return cs.getSf().openSession().createCriteria(Player.class).list();
        }
     
        @Override //mencari data yang berelasi
        public List<Player> search(String a) {
            Criteria cr = cs.getSf().openSession().createCriteria(Player.class);
            cr.createAlias("club", "c");
            cr.add(Restrictions.or(Restrictions.like("c.namaClub", a, MatchMode.ANYWHERE),
                                   Restrictions.like("namaPemain", a, MatchMode.ANYWHERE)));
            return cr.list();
        }
         
    }
    /*
     * To change this license header, choose License Headers in Project Properties.
     * To change this template file, choose Tools | Templates
     * and open the template in the editor.
     */
    package listplayer.implement;
    
    import java.util.List;
    import listplayer.interfaces.interPlayer;
    import listplayer.model.Player;
    import org.hibernate.Criteria;
    import org.hibernate.HibernateException;
    import org.hibernate.criterion.MatchMode;
    import org.hibernate.criterion.Projections;
    import org.hibernate.criterion.Restrictions;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Repository;
    
    @Repository
    public class implPlayer implements interPlayer {
        @Autowired
        configSession cs;
    
        @Override //save dan update data
        public void saveOrUpdate(Player p) {
            if (p.getIdPemain()==null) {
                cs.create(p);
            }else{
                cs.update(p);
            }
        }
    
        @Override //delete data
        public void delete(Player p) {
            cs.delete(p);
        }
    
        @Override //auto id
        public void autoId(Player p) {
            try {
                Criteria cr = cs.getSf().openSession().createCriteria(Player.class);
                cr.setProjection(Projections.max("idPemain"));
                Object o = cr.uniqueResult();
                String auto = ""+(Integer.parseInt(o.toString().substring(2))+1);
                String nol = "";
                if (auto.length()==1){
                    nol = "00";
                } else if (auto.length()==2){
                    nol = "0";
                }else if (auto.length()==3){
                    nol = "";
                }    
                p.setIdPemain("P."+nol+auto);
            } catch (NumberFormatException | HibernateException e) {
            }
        }
    
        @Override //menampilkan data
        public List<Player> getAll() {
            return cs.getSf().openSession().createCriteria(Player.class).list();
        }
    
        @Override //mencari data yang berelasi
        public List<Player> search(String a) {
            Criteria cr = cs.getSf().openSession().createCriteria(Player.class);
            cr.createAlias("club", "c");
            cr.add(Restrictions.or(Restrictions.like("c.namaClub", a, MatchMode.ANYWHERE),
                                   Restrictions.like("namaPemain", a, MatchMode.ANYWHERE)));
            return cr.list();
        }
        
    }
    
  • Nah, Sebelum melenggang ke desain harus ada config dulu, ini berguna saat menulis source di controller.
  • Package listplayer.configure nama class configAnimasi.java
  • 01
    02
    03
    04
    05
    06
    07
    08
    09
    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
    /*
        Animation For JavaFX.
    */
     
    package listplayer.configure;
     
    import javafx.animation.Interpolator;
    import javafx.animation.Timeline;
    import javafx.animation.Transition;
    import javafx.beans.value.ChangeListener;
    import javafx.beans.value.ObservableValue;
    import javafx.scene.CacheHint;
    import javafx.scene.Node;
    import javafx.util.Duration;
     
    /*
        Created on : Sep 13, 2014, 8:45:48 AM
        Source     : Code Master
        Author     : herudi-pc
    */
     
    public class configAnimasi extends Transition {
        protected static final Interpolator WEB_EASE = Interpolator.SPLINE(0.25, 0.1, 0.25, 1);
        protected final Node node;
        protected Timeline timeline;
        private boolean oldCache = false;
        private CacheHint oldCacheHint = CacheHint.DEFAULT;
        private final boolean useCache;
     
        /**
         * @param node The node that is being animated by the timeline
         * @param timeline The timeline for the animation, it should be from 0 to 1 seconds
         */
        public configAnimasi(final Node node, final Timeline timeline) {
            this(node, timeline, true);
        }
         
        /**
         * @param node The node that is being animated by the timeline
         * @param timeline The timeline for the animation, it should be from 0 to 1 seconds
         * @param useCache When true the node is cached as image during the animation
         */
        public configAnimasi(final Node node, final Timeline timeline, final boolean useCache) {
            this.node = node;
            this.timeline = timeline;
            this.useCache = useCache;
            statusProperty().addListener(new ChangeListener<Status>() {
                @Override public void changed(ObservableValue<? extends Status> ov, Status t, Status newStatus) {
                    switch(newStatus) {
                        case RUNNING:
                            starting();
                            break;
                        default:
                            stopping();
                            break;
                    }
                }
            });
        }
         
        /**
         * Called when the animation is starting
         */
        protected void starting() {
            if (useCache) {
                oldCache = node.isCache();
                oldCacheHint = node.getCacheHint();
                node.setCache(true);
                node.setCacheHint(CacheHint.SPEED);
            }
        }
         
        /**
         * Called when the animation is stopping
         */
        protected void stopping() {
            if (useCache) {
                node.setCache(oldCache);
                node.setCacheHint(oldCacheHint);
            }
        }
     
        @Override
        protected void interpolate(double d) {
            timeline.playFrom(Duration.seconds(d));
            timeline.stop();
        }
     
    }
    /*
        Animation For JavaFX.
    */
    
    package listplayer.configure;
    
    import javafx.animation.Interpolator;
    import javafx.animation.Timeline;
    import javafx.animation.Transition;
    import javafx.beans.value.ChangeListener;
    import javafx.beans.value.ObservableValue;
    import javafx.scene.CacheHint;
    import javafx.scene.Node;
    import javafx.util.Duration;
    
    /* 
        Created on : Sep 13, 2014, 8:45:48 AM
        Source     : Code Master
        Author     : herudi-pc
    */
    
    public class configAnimasi extends Transition {
        protected static final Interpolator WEB_EASE = Interpolator.SPLINE(0.25, 0.1, 0.25, 1);
        protected final Node node;
        protected Timeline timeline;
        private boolean oldCache = false;
        private CacheHint oldCacheHint = CacheHint.DEFAULT;
        private final boolean useCache;
    
        /** 
         * @param node The node that is being animated by the timeline
         * @param timeline The timeline for the animation, it should be from 0 to 1 seconds
         */
        public configAnimasi(final Node node, final Timeline timeline) {
            this(node, timeline, true);
        }
        
        /**
         * @param node The node that is being animated by the timeline
         * @param timeline The timeline for the animation, it should be from 0 to 1 seconds
         * @param useCache When true the node is cached as image during the animation
         */
        public configAnimasi(final Node node, final Timeline timeline, final boolean useCache) {
            this.node = node;
            this.timeline = timeline;
            this.useCache = useCache;
            statusProperty().addListener(new ChangeListener<Status>() {
                @Override public void changed(ObservableValue<? extends Status> ov, Status t, Status newStatus) {
                    switch(newStatus) {
                        case RUNNING:
                            starting();
                            break;
                        default: 
                            stopping();
                            break;
                    }
                }
            });
        }
        
        /**
         * Called when the animation is starting
         */
        protected void starting() {
            if (useCache) {
                oldCache = node.isCache();
                oldCacheHint = node.getCacheHint();
                node.setCache(true);
                node.setCacheHint(CacheHint.SPEED);
            }
        }
        
        /**
         * Called when the animation is stopping
         */
        protected void stopping() {
            if (useCache) {
                node.setCache(oldCache);
                node.setCacheHint(oldCacheHint);
            }
        }
    
        @Override 
        protected void interpolate(double d) {
            timeline.playFrom(Duration.seconds(d));
            timeline.stop();
        }
    
    }
    
  • Package listplayer.configure nama class configScene.java
  • 01
    02
    03
    04
    05
    06
    07
    08
    09
    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
    /*
     * To change this license header, choose License Headers in Project Properties.
     * To change this template file, choose Tools | Templates
     * and open the template in the editor.
     */
    package listplayer.configure;
     
    import java.io.IOException;
    import java.net.URL;
    import java.util.ResourceBundle;
    import javafx.concurrent.Task;
    import javafx.fxml.FXMLLoader;
    import javafx.scene.Parent;
    import javafx.scene.control.Alert;
    import javafx.scene.control.ProgressBar;
    import javafx.scene.control.TableView;
    import javafx.scene.layout.AnchorPane;
    import javafx.scene.layout.HBox;
    import javafx.stage.StageStyle;
    import listplayer.animation.loadingStatusIn;
    import listplayer.animation.loadingStatusUp;
     
    /**
     *
     * @author herudi-pc
     */
    public class configScene {
     
        public configScene() {
        }
         
        //dialog jfx
        public static void createDialog(Alert.AlertType alertType, String s){
            Alert alert = new Alert(alertType,s);
            alert.initStyle(StageStyle.UTILITY);
            alert.setTitle("Info");
            alert.showAndWait();
        }
         
        //select table auto, saat save data
        public static void selectedTable(Integer click, Integer select, TableView tv){
            if (click==1) {
                tv.getSelectionModel().select(select);
                tv.scrollTo(select);
            }else{
                tv.getSelectionModel().selectLast();
                int table = tv.getSelectionModel().getSelectedIndex();
                tv.scrollTo(table);
            }
        }
         
        //pengaturan select saat di klik
        public static void onSelectTable(Integer click, Integer select, TableView tv){
            click = 1;
            select = tv.getSelectionModel().getSelectedIndex();
        }
         
        //loading progress bar
        public static void progressBarLoading(HBox hb, ProgressBar pb){
            new loadingStatusIn(hb).play();
            new loadingStatusUp(hb).play();
            Task<Void> task = new Task<Void>() {
              @Override public Void call() {
                for (int i = 1; i < 100; i++) {
                  try {
                    Thread.sleep(4);
                  } catch (InterruptedException e) {
                  }
                  updateProgress(i+1, 100);
                }
                return null;
              }
            };
            pb.progressProperty().bind(task.progressProperty());
            Thread th = new Thread(task);
            th.start();
        }
         
        //load Pane
        public void loadAnchorPane(AnchorPane ap, String a){
            try {
                Parent p = FXMLLoader.load(getClass().getResource("/listplayer/view/"+a));
                ap.getChildren().add(p);  
            } catch (IOException e) {
            }  
        }
    }
    /*
     * To change this license header, choose License Headers in Project Properties.
     * To change this template file, choose Tools | Templates
     * and open the template in the editor.
     */
    package listplayer.configure;
    
    import java.io.IOException;
    import java.net.URL;
    import java.util.ResourceBundle;
    import javafx.concurrent.Task;
    import javafx.fxml.FXMLLoader;
    import javafx.scene.Parent;
    import javafx.scene.control.Alert;
    import javafx.scene.control.ProgressBar;
    import javafx.scene.control.TableView;
    import javafx.scene.layout.AnchorPane;
    import javafx.scene.layout.HBox;
    import javafx.stage.StageStyle;
    import listplayer.animation.loadingStatusIn;
    import listplayer.animation.loadingStatusUp;
    
    /**
     *
     * @author herudi-pc
     */
    public class configScene {
    
        public configScene() {
        }
        
        //dialog jfx
        public static void createDialog(Alert.AlertType alertType, String s){
            Alert alert = new Alert(alertType,s);
            alert.initStyle(StageStyle.UTILITY);
            alert.setTitle("Info");
            alert.showAndWait();
        }
        
        //select table auto, saat save data
        public static void selectedTable(Integer click, Integer select, TableView tv){
            if (click==1) {
                tv.getSelectionModel().select(select);
                tv.scrollTo(select);
            }else{
                tv.getSelectionModel().selectLast();
                int table = tv.getSelectionModel().getSelectedIndex();
                tv.scrollTo(table);
            }
        }
        
        //pengaturan select saat di klik
        public static void onSelectTable(Integer click, Integer select, TableView tv){
            click = 1;
            select = tv.getSelectionModel().getSelectedIndex();
        }
        
        //loading progress bar
        public static void progressBarLoading(HBox hb, ProgressBar pb){
            new loadingStatusIn(hb).play();
            new loadingStatusUp(hb).play();
            Task<Void> task = new Task<Void>() {
              @Override public Void call() {
                for (int i = 1; i < 100; i++) {
                  try {
                    Thread.sleep(4);
                  } catch (InterruptedException e) {
                  }
                  updateProgress(i+1, 100);
                }
                return null;
              }
            };
            pb.progressProperty().bind(task.progressProperty());
            Thread th = new Thread(task);
            th.start();
        }
        
        //load Pane
        public void loadAnchorPane(AnchorPane ap, String a){
            try {
                Parent p = FXMLLoader.load(getClass().getResource("/listplayer/view/"+a));
                ap.getChildren().add(p);   
            } catch (IOException e) {
            }   
        }
    }
    
  • Package listplayer.configure nama class configSpring.java
  • 01
    02
    03
    04
    05
    06
    07
    08
    09
    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
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    package listplayer.configure;
     
    import org.springframework.beans.BeansException;
    import org.springframework.context.ApplicationContext;
    import org.springframework.context.support.ClassPathXmlApplicationContext;
     
    /**
     *
     * @author herudi-pc
     */
    public class configSpring {
     
        private ApplicationContext applicationContext;
        private static configSpring provider;
     
        private configSpring() throws ExceptionInInitializerError {
            try {
                this.applicationContext = new ClassPathXmlApplicationContext("appConfig.xml");
            } catch (BeansException ex) {
                System.err.print("error " + ex);
            }
        }
     
        public synchronized static configSpring getInstance() throws ExceptionInInitializerError {
            configSpring tempProvider;
            if (provider == null) {
                provider = new configSpring();
                tempProvider = provider;
            }else if(provider.getApplicationContext()==null){
                provider=new configSpring();
                tempProvider=provider;
            }else{
                tempProvider=provider;
            }
            return tempProvider;
        }
     
        public ApplicationContext getApplicationContext() {
            return applicationContext;
        }
     
        public void setApplicationContext(ApplicationContext applicationContext) {
            this.applicationContext = applicationContext;
        }
    }
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    package listplayer.configure;
    
    import org.springframework.beans.BeansException;
    import org.springframework.context.ApplicationContext;
    import org.springframework.context.support.ClassPathXmlApplicationContext;
    
    /**
     *
     * @author herudi-pc
     */
    public class configSpring {
    
        private ApplicationContext applicationContext;
        private static configSpring provider;
    
        private configSpring() throws ExceptionInInitializerError {
            try {
                this.applicationContext = new ClassPathXmlApplicationContext("appConfig.xml");
            } catch (BeansException ex) {
                System.err.print("error " + ex);
            }
        }
    
        public synchronized static configSpring getInstance() throws ExceptionInInitializerError {
            configSpring tempProvider;
            if (provider == null) {
                provider = new configSpring();
                tempProvider = provider;
            }else if(provider.getApplicationContext()==null){
                provider=new configSpring();
                tempProvider=provider;
            }else{
                tempProvider=provider;
            }
            return tempProvider;
        }
    
        public ApplicationContext getApplicationContext() {
            return applicationContext;
        }
    
        public void setApplicationContext(ApplicationContext applicationContext) {
            this.applicationContext = applicationContext;
        }
    }
    
  • Oke selanjutnya di aplikasi ane, ada beberapa animasi untuk memperindah tampilan aplikasinya.

  • penjelasan gambar diatas, saat tombol refresh di klik maka akan muncul progressBar melayang dari bawah ke atas.
  • Package listplayer.animation nama class loadingStatusIn.java
  • 01
    02
    03
    04
    05
    06
    07
    08
    09
    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
    package listplayer.animation;
     
    import listplayer.configure.configAnimasi;
    import javafx.animation.KeyFrame;
    import javafx.animation.KeyValue;
    import javafx.animation.TimelineBuilder;
    import javafx.scene.Node;
    import javafx.util.Duration;
     
    /*
        Created on : Sep 13, 2014, 8:45:48 AM
        Source     : Code Master
        Author     : herudi-pc
    */
     
    public class loadingStatusIn extends configAnimasi {
        /**
         * @param node The node to affect
         */
        public loadingStatusIn(final Node node) {
            super(
                node,
                TimelineBuilder.create()
                    .keyFrames(
                        new KeyFrame(Duration.millis(0),   
                            new KeyValue(node.opacityProperty(), 0, WEB_EASE),
                            new KeyValue(node.translateYProperty(), 20, WEB_EASE)
                        ),
                        new KeyFrame(Duration.millis(500),   
                            new KeyValue(node.opacityProperty(), 1, WEB_EASE),
                            new KeyValue(node.translateYProperty(), 0, WEB_EASE)
                        )
                    )
                    .build()
                );
            setCycleDuration(Duration.seconds(1));
            setDelay(Duration.seconds(0));
            node.toFront();
        }
    }
    package listplayer.animation;
    
    import listplayer.configure.configAnimasi;
    import javafx.animation.KeyFrame;
    import javafx.animation.KeyValue;
    import javafx.animation.TimelineBuilder;
    import javafx.scene.Node;
    import javafx.util.Duration;
    
    /* 
        Created on : Sep 13, 2014, 8:45:48 AM
        Source     : Code Master
        Author     : herudi-pc
    */
    
    public class loadingStatusIn extends configAnimasi {
        /** 
         * @param node The node to affect
         */
        public loadingStatusIn(final Node node) {
            super(
                node,
                TimelineBuilder.create()
                    .keyFrames(
                        new KeyFrame(Duration.millis(0),    
                            new KeyValue(node.opacityProperty(), 0, WEB_EASE),
                            new KeyValue(node.translateYProperty(), 20, WEB_EASE)
                        ),
                        new KeyFrame(Duration.millis(500),    
                            new KeyValue(node.opacityProperty(), 1, WEB_EASE),
                            new KeyValue(node.translateYProperty(), 0, WEB_EASE)
                        )
                    )
                    .build()
                );
            setCycleDuration(Duration.seconds(1));
            setDelay(Duration.seconds(0));
            node.toFront();
        }
    }
    
  • Package listplayer.animation nama class loadingStatusUp.java
  • 01
    02
    03
    04
    05
    06
    07
    08
    09
    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
    package listplayer.animation;
     
    import listplayer.configure.configAnimasi;
    import javafx.animation.KeyFrame;
    import javafx.animation.KeyValue;
    import javafx.animation.TimelineBuilder;
    import javafx.scene.Node;
    import javafx.util.Duration;
     
    /*
        Created on : Sep 13, 2014, 8:45:48 AM
        Source     : Code Master
        Author     : herudi-pc
    */
     
    public class loadingStatusUp extends configAnimasi {
        /**
         * @param node The node to affect
         */
        public loadingStatusUp(final Node node) {
            super(
                node,
                TimelineBuilder.create()
                    .keyFrames(
                        new KeyFrame(Duration.millis(0),   
                            new KeyValue(node.opacityProperty(), 1, WEB_EASE),
                            new KeyValue(node.translateYProperty(), 0, WEB_EASE)
                        ),
                        new KeyFrame(Duration.millis(200),   
                            new KeyValue(node.opacityProperty(), 0, WEB_EASE),
                            new KeyValue(node.translateYProperty(), -20, WEB_EASE)
                        )
                    )
                    .build()
                );
            setCycleDuration(Duration.seconds(1));
            setDelay(Duration.seconds(1));
        }
     
        @Override protected void stopping() {
            super.stopping();
            node.setTranslateY(0); // restore default
        }
    }
    package listplayer.animation;
    
    import listplayer.configure.configAnimasi;
    import javafx.animation.KeyFrame;
    import javafx.animation.KeyValue;
    import javafx.animation.TimelineBuilder;
    import javafx.scene.Node;
    import javafx.util.Duration;
    
    /* 
        Created on : Sep 13, 2014, 8:45:48 AM
        Source     : Code Master
        Author     : herudi-pc
    */
    
    public class loadingStatusUp extends configAnimasi {
        /**
         * @param node The node to affect
         */
        public loadingStatusUp(final Node node) {
            super(
                node,
                TimelineBuilder.create()
                    .keyFrames(
                        new KeyFrame(Duration.millis(0),    
                            new KeyValue(node.opacityProperty(), 1, WEB_EASE),
                            new KeyValue(node.translateYProperty(), 0, WEB_EASE)
                        ),
                        new KeyFrame(Duration.millis(200),    
                            new KeyValue(node.opacityProperty(), 0, WEB_EASE),
                            new KeyValue(node.translateYProperty(), -20, WEB_EASE)
                        )
                    )
                    .build()
                );
            setCycleDuration(Duration.seconds(1));
            setDelay(Duration.seconds(1));
        }
    
        @Override protected void stopping() {
            super.stopping();
            node.setTranslateY(0); // restore default
        }
    }
    
  • Selanjutnya menyisipkan gambar di bawah ini. di Package listplayer.image dengan nama header.png

  • Selanjutnya membuat CSS dulu aja, agar pas desain kita tahu penampilannya. ada tiga css yang ada dalam aplikasi ane.

  • Package listplayer.css nama CSS listPlayerCss.css
  • 001
    002
    003
    004
    005
    006
    007
    008
    009
    010
    011
    012
    013
    014
    015
    016
    017
    018
    019
    020
    021
    022
    023
    024
    025
    026
    027
    028
    029
    030
    031
    032
    033
    034
    035
    036
    037
    038
    039
    040
    041
    042
    043
    044
    045
    046
    047
    048
    049
    050
    051
    052
    053
    054
    055
    056
    057
    058
    059
    060
    061
    062
    063
    064
    065
    066
    067
    068
    069
    070
    071
    072
    073
    074
    075
    076
    077
    078
    079
    080
    081
    082
    083
    084
    085
    086
    087
    088
    089
    090
    091
    092
    093
    094
    095
    096
    097
    098
    099
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    /*
    To change this license header, choose License Headers in Project Properties.
    To change this template file, choose Tools | Templates
    and open the template in the editor.
    */
    /*
        Created on : Nov 27, 2014, 8:38:47 AM
        Author     : herudi-pc
    */
     
    .paneInput{
        -fx-background-color#f8f7f7;
        -fx-border-colorwhite white white #e1e1e1;
    }
     
    .paneList{
        -fx-background-color#ffffff;
    }
     
    .hyperlink{
        -fx-text-fill: #cb0006;
    }
     
    .headerPane{
        -fx-background-color:  derive(grey, -30%);
    }
     
    .button {
       -fx-color: #3184ba !important;
    }
     
    .button:hover{
        -fx-background-color: linear-gradient(#333333,#666666);
    }
     
    .table-view .column-header, .table-view .filler {
        -fx-size: 35;
        -fx-border-width: 0 0 0 0;
        -fx-background-color: derive(grey, -30%);
        -fx-border-color:
            transparent
            transparent
            derive(-fx-base, 80%)
            transparent;
        -fx-border-insets: 0 10 1 0;
    }
     
    .table-view .column-header .label {
        -fx-font-size: 12px;
        -fx-font-family: "Segoe UI";
        -fx-text-fill: white;
        -fx-alignment: center-left;
    }
     
    .table-view:focused .table-row-cell:filled:focused:selected {
        -fx-background-color: -fx-focus-color;
    }
     
    .table-cell {    
        -fx-cell-size: 1.5em;
        -fx-padding: 0.2em 0em 0.1em 0.1em;
        -fx-font: 13px "Segoe UI"
        -fx-alignment: bottom-left;
    }
     
    .table-row-cell:empty {
        -fx-background-color: #f8f8f8;
        -fx-base: transparent;
        -fx-control-inner-background: transparent;
        -fx-table-cell-border-color: transparent;
        -fx-table-header-border-color: transparent;
        -fx-padding: 0;
    }
       
    .table-row-cell:empty .table-cell {
        -fx-border-width: 0px;
    }
     
    .scroll-bar .thumb{
        -fx-background-color: #cdcdcd;
        -fx-background-insets: 0;
        -fx-background-radius: 0;
    }
      
    .scroll-bar .thumb:hover {
        -fx-color: #dadada;
    }
      
    /* The following is not working. Maybe related to RT-10521*/
    .scroll-bar .thumb:pressed {
        -fx-background-color: #606060;
    }
      
      
    .scroll-bar .track {
         -fx-background-color: #f0f0f0;
        -fx-background-insets: 0;
        -fx-background-radius: 0;
    }
    .scroll-bar .track-background {
         -fx-background-color: #f0f0f0;
        -fx-background-insets: 0;
    }
      
    .scroll-bar .increment-button, .scroll-bar .decrement-button {
        -fx-background-color: #f0f0f0;
        -fx-background-insets: 0;
        -fx-background-radius: 0;
          
        -fx-padding: 0.25em; /* 3 */
    }
      
    .scroll-bar .increment-button:hover, .scroll-bar .decrement-button:hover  {
        -fx-background-color: #dadada;
    }
      
    .scroll-bar .increment-button:pressed, .scroll-bar .decrement-button:pressed {
        -fx-background-color: #606060;
    }
      
    .scroll-bar:horizontal .increment-arrow {
        -fx-background-color: -fx-mark-highlight-color, -fx-mark-color;
        -fx-background-insets: 1 0 -1 0, 0;
        -fx-padding: 0.5em 0.333333em 0.0em 0.0em; /* 6 4 0 0 */
        -fx-shape: "M7.626,12.876L4.251,8.751H7.14L11,12.876L7.14,17H4.251L7.626,12.876z";
    }
      
    .scroll-bar:vertical .increment-arrow {
        -fx-background-color: -fx-mark-highlight-color, -fx-mark-color;
        -fx-background-insets: 1 0 -1 0, 0;
        -fx-padding: 0.333333em 0.5em 0.0em 0.0em; /* 4 6 0 0 */
        -fx-shape: "M8.124,13.625l4.125-3.375v2.889l-4.125,3.86L4,13.139V10.25L8.124,13.625z";
    }
      
    .scroll-bar .increment-button:pressed .increment-arrow {
        -fx-background-color: white, white;
    }
      
    .scroll-bar:horizontal .decrement-arrow {
        -fx-background-color: -fx-mark-highlight-color, -fx-mark-color;
        -fx-background-insets: 1 0 -1 0, 0;
        -fx-padding: 0.5em 0.333333em 0.0em 0.0em; /* 6 4 0 0 */
        -fx-shape: "M11,17H8.111l-3.86-4.124l3.86-4.125H11l-3.375,4.125L11,17z";
    }
      
    .scroll-bar:vertical .decrement-arrow {
        -fx-background-color: -fx-mark-highlight-color, -fx-mark-color;
        -fx-background-insets: 1 0 -1 0, 0;
        -fx-padding: 0.333333em 0.5em 0.0em 0.0em; /* 4 6 0 0 */
        -fx-shape: "M4,17v-2.889l4.124-3.86l4.125,3.86V17l-4.125-3.375L4,17z";
    }
      
    .scroll-bar .decrement-button:pressed .decrement-arrow {
        -fx-background-color: white, white;
    }
      
    .scroll-bar:disabled {
        -fx-opacity: 0.4;
    }
      
    /*******************************************************************************
     *                                                                             *
     * ScrollPane                                                                  *
     *                                                                             *
     ******************************************************************************/
      
    .scroll-pane {
        -fx-background-color: transparent,-fx-background;
    }
      
    .scroll-pane .corner {
        -fx-background-color: white, #f0f0f0;
    }
    /*
    To change this license header, choose License Headers in Project Properties.
    To change this template file, choose Tools | Templates
    and open the template in the editor.
    */
    /* 
        Created on : Nov 27, 2014, 8:38:47 AM
        Author     : herudi-pc
    */
    
    .paneInput{
        -fx-background-color:  #f8f7f7;
        -fx-border-color:  white white white #e1e1e1;
    }
    
    .paneList{
        -fx-background-color:  #ffffff;
    }
    
    .hyperlink{
        -fx-text-fill: #cb0006;
    }
    
    .headerPane{
        -fx-background-color:  derive(grey, -30%);
    }
    
    .button {
       -fx-color: #3184ba !important;
    }
    
    .button:hover{
        -fx-background-color: linear-gradient(#333333,#666666);
    }
    
    .table-view .column-header, .table-view .filler {
        -fx-size: 35;
        -fx-border-width: 0 0 0 0;
        -fx-background-color: derive(grey, -30%);
        -fx-border-color: 
            transparent
            transparent
            derive(-fx-base, 80%) 
            transparent;
        -fx-border-insets: 0 10 1 0;
    }
    
    .table-view .column-header .label {
        -fx-font-size: 12px;
        -fx-font-family: "Segoe UI";
        -fx-text-fill: white;
        -fx-alignment: center-left;
    }
    
    .table-view:focused .table-row-cell:filled:focused:selected {
        -fx-background-color: -fx-focus-color;
    }
    
    .table-cell {     
        -fx-cell-size: 1.5em;
        -fx-padding: 0.2em 0em 0.1em 0.1em;
        -fx-font: 13px "Segoe UI";  
        -fx-alignment: bottom-left;
    }
    
    .table-row-cell:empty {
        -fx-background-color: #f8f8f8;
        -fx-base: transparent;
        -fx-control-inner-background: transparent;
        -fx-table-cell-border-color: transparent;
        -fx-table-header-border-color: transparent;
        -fx-padding: 0;
    }
      
    .table-row-cell:empty .table-cell {
        -fx-border-width: 0px;
    }
    
    .scroll-bar .thumb{
        -fx-background-color: #cdcdcd;
        -fx-background-insets: 0;
        -fx-background-radius: 0;
    }
     
    .scroll-bar .thumb:hover {
        -fx-color: #dadada;
    }
     
    /* The following is not working. Maybe related to RT-10521*/
    .scroll-bar .thumb:pressed {
        -fx-background-color: #606060;
    }
     
     
    .scroll-bar .track {
         -fx-background-color: #f0f0f0;
        -fx-background-insets: 0;
        -fx-background-radius: 0;
    }
    .scroll-bar .track-background {
         -fx-background-color: #f0f0f0;
        -fx-background-insets: 0;
    }
     
    .scroll-bar .increment-button, .scroll-bar .decrement-button {
        -fx-background-color: #f0f0f0;
        -fx-background-insets: 0;
        -fx-background-radius: 0;
         
        -fx-padding: 0.25em; /* 3 */
    }
     
    .scroll-bar .increment-button:hover, .scroll-bar .decrement-button:hover  {
        -fx-background-color: #dadada;
    }
     
    .scroll-bar .increment-button:pressed, .scroll-bar .decrement-button:pressed {
        -fx-background-color: #606060;
    }
     
    .scroll-bar:horizontal .increment-arrow {
        -fx-background-color: -fx-mark-highlight-color, -fx-mark-color;
        -fx-background-insets: 1 0 -1 0, 0;
        -fx-padding: 0.5em 0.333333em 0.0em 0.0em; /* 6 4 0 0 */
        -fx-shape: "M7.626,12.876L4.251,8.751H7.14L11,12.876L7.14,17H4.251L7.626,12.876z";
    }
     
    .scroll-bar:vertical .increment-arrow {
        -fx-background-color: -fx-mark-highlight-color, -fx-mark-color;
        -fx-background-insets: 1 0 -1 0, 0;
        -fx-padding: 0.333333em 0.5em 0.0em 0.0em; /* 4 6 0 0 */
        -fx-shape: "M8.124,13.625l4.125-3.375v2.889l-4.125,3.86L4,13.139V10.25L8.124,13.625z";
    }
     
    .scroll-bar .increment-button:pressed .increment-arrow {
        -fx-background-color: white, white;
    }
     
    .scroll-bar:horizontal .decrement-arrow {
        -fx-background-color: -fx-mark-highlight-color, -fx-mark-color;
        -fx-background-insets: 1 0 -1 0, 0;
        -fx-padding: 0.5em 0.333333em 0.0em 0.0em; /* 6 4 0 0 */
        -fx-shape: "M11,17H8.111l-3.86-4.124l3.86-4.125H11l-3.375,4.125L11,17z";
    }
     
    .scroll-bar:vertical .decrement-arrow {
        -fx-background-color: -fx-mark-highlight-color, -fx-mark-color;
        -fx-background-insets: 1 0 -1 0, 0;
        -fx-padding: 0.333333em 0.5em 0.0em 0.0em; /* 4 6 0 0 */
        -fx-shape: "M4,17v-2.889l4.124-3.86l4.125,3.86V17l-4.125-3.375L4,17z";
    }
     
    .scroll-bar .decrement-button:pressed .decrement-arrow {
        -fx-background-color: white, white;
    }
     
    .scroll-bar:disabled {
        -fx-opacity: 0.4;
    }
     
    /*******************************************************************************
     *                                                                             *
     * ScrollPane                                                                  *
     *                                                                             *
     ******************************************************************************/
     
    .scroll-pane {
        -fx-background-color: transparent,-fx-background;
    }
     
    .scroll-pane .corner {
        -fx-background-color: white, #f0f0f0;
    }
    
  • Package listplayer.css nama CSS loadTable.css
  • 01
    02
    03
    04
    05
    06
    07
    08
    09
    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
    /*
    To change this license header, choose License Headers in Project Properties.
    To change this template file, choose Tools | Templates
    and open the template in the editor.
    */
    /*
        Created on : Nov 27, 2014, 9:52:25 AM
        Author     : herudi-pc
    */
     
    .table-view .column-header, .table-view .filler {
        -fx-background-color: white;
    }
     
    .table-view .column-header .label {
        -fx-font-size: 12px;
        -fx-font-family: "Segoe UI";
        -fx-text-fill: white;
        -fx-alignment: center-left;
    }
     
    .table-view:focused .table-row-cell:filled:focused:selected {
        -fx-background-color: -fx-focus-color;
    }
     
    .table-cell {    
        -fx-cell-size: 1.5em;
        -fx-padding: 0.2em 0em 0.1em 0.1em;
        -fx-font: 13px "Segoe UI"
        -fx-alignment: bottom-left;
    }
     
    .table-row-cell:empty {
        -fx-background-color: #f8f8f8;
        -fx-base: transparent;
        -fx-control-inner-background: transparent;
        -fx-table-cell-border-color: transparent;
        -fx-table-header-border-color: transparent;
        -fx-padding: 0;
    }
       
    .table-row-cell:empty .table-cell {
        -fx-border-width: 0px;
    }
    /*
    To change this license header, choose License Headers in Project Properties.
    To change this template file, choose Tools | Templates
    and open the template in the editor.
    */
    /* 
        Created on : Nov 27, 2014, 9:52:25 AM
        Author     : herudi-pc
    */
    
    .table-view .column-header, .table-view .filler {
        -fx-background-color: white;
    }
    
    .table-view .column-header .label {
        -fx-font-size: 12px;
        -fx-font-family: "Segoe UI";
        -fx-text-fill: white;
        -fx-alignment: center-left;
    }
    
    .table-view:focused .table-row-cell:filled:focused:selected {
        -fx-background-color: -fx-focus-color;
    }
    
    .table-cell {     
        -fx-cell-size: 1.5em;
        -fx-padding: 0.2em 0em 0.1em 0.1em;
        -fx-font: 13px "Segoe UI";  
        -fx-alignment: bottom-left;
    }
    
    .table-row-cell:empty {
        -fx-background-color: #f8f8f8;
        -fx-base: transparent;
        -fx-control-inner-background: transparent;
        -fx-table-cell-border-color: transparent;
        -fx-table-header-border-color: transparent;
        -fx-padding: 0;
    }
      
    .table-row-cell:empty .table-cell {
        -fx-border-width: 0px;
    }
    
  • Package listplayer.css nama CSS progressInfo.css
  • 01
    02
    03
    04
    05
    06
    07
    08
    09
    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
    /*
    To change this license header, choose License Headers in Project Properties.
    To change this template file, choose Tools | Templates
    and open the template in the editor.
    */
    /*
        Created on : Sep 13, 2014, 8:45:48 AM
        Author     : herudi-pc
    */
     
    .progress-bar {
        -fx-background-color:
            -fx-box-border,
            linear-gradient(to bottom, derive(-fx-color,30%) 5%, derive(-fx-color,-17%));
        -fx-background-insets: 0, 1;
        -fx-indeterminate-bar-length: 60;
        -fx-indeterminate-bar-escape: true;
        -fx-indeterminate-bar-flip: true;
        -fx-indeterminate-bar-animation-time: 2;
        -fx-focus-traversable: true;
        -fx-border-color:white;
    }
     
    .progress-bar .bar {
        -fx-background-color: #42539d;
        -fx-background-insets: 0, 1, 2;
        -fx-padding: 0.416667em; /* 5 */
        -fx-border-color:white;
    }
     
    .progress-bar:indeterminate .bar {
        -fx-background-color: derive(grey, -60%);
    }
     
    .progress-bar .track {
         -fx-background-color:
            white;
        -fx-background-insets:  0, 1;
    }
     
    .progress-bar:disabled {
        -fx-opacity: 1.0
    }
    /*
    To change this license header, choose License Headers in Project Properties.
    To change this template file, choose Tools | Templates
    and open the template in the editor.
    */
    /* 
        Created on : Sep 13, 2014, 8:45:48 AM
        Author     : herudi-pc
    */
    
    .progress-bar {
        -fx-background-color:
            -fx-box-border,
            linear-gradient(to bottom, derive(-fx-color,30%) 5%, derive(-fx-color,-17%));
        -fx-background-insets: 0, 1;
        -fx-indeterminate-bar-length: 60;
        -fx-indeterminate-bar-escape: true;
        -fx-indeterminate-bar-flip: true;
        -fx-indeterminate-bar-animation-time: 2;
        -fx-focus-traversable: true;
        -fx-border-color:white;
    }
    
    .progress-bar .bar {
        -fx-background-color: #42539d;
        -fx-background-insets: 0, 1, 2;
        -fx-padding: 0.416667em; /* 5 */
        -fx-border-color:white;
    }
    
    .progress-bar:indeterminate .bar {
        -fx-background-color: derive(grey, -60%);
    }
    
    .progress-bar .track {
         -fx-background-color:
            white;
        -fx-background-insets:  0, 1;
    }
    
    .progress-bar:disabled {
        -fx-opacity: 1.0
    }
    
  • Akhirnya sampai juga ke tahap desain view. klik kanan di package listplayer.view pilih new >> empty FXML. di aplikasi ane ada tiga file FXML.


  • file masterListPlayer.fxml

  • silahkan desain dengan baik dan benar. jangan lupa menamakan fx:id nya dan nama controllernya jangan lupa juga import CSS nya. 
  • jika belum bisa mendesain di scene builder, agan dan aganwati tinggal copas aja source dibawah ini. Package listplayer.view nama file masterListPlayer.fxml. //klik kanan filenya dan pilih edit. silahkan copi dan paste. semoga bisa dipelajari. bila ada error beritahu ane.
  • Klik Disini masterListPlayer.fxml.
  • file player.fxml

  • file club.fxml

  • setelah kita membuat model dan view, sekarang adalah tahap akhir yaitu membuat controller dari 3 file fxml tadi. ingat 1 file fxml, 1 controller. tidak usah repot untuk membuat controller. karena di Netbeans bisa generate otomatis controllernya. klik kanan setiap file dan pilih Make Controller. karena ane menyeting dan menaruh controllernya supaya ada di Package listplayer.controller. maka jangan heran di Package tersebut tiba2 ada 3 class controller


  • Package listplayer.controller nama class playerController.java
  • Klik Disini playerController.java.
  • Package listplayer.controller nama class clubController.java
  • Klik Disini clubController.java.

    • Oke deh aplikasinya hampir 100% selesai. sekarang tinggal membuat main Class. yang akan ditampilkan pertama kali adalah masterListPlayer.fxml
    • Package listPlayer nama main class listPlayer.java
    • 01
      02
      03
      04
      05
      06
      07
      08
      09
      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
      /*
       * To change this license header, choose License Headers in Project Properties.
       * To change this template file, choose Tools | Templates
       * and open the template in the editor.
       */
      package listplayer;
       
      import javafx.application.Application;
      import javafx.fxml.FXMLLoader;
      import javafx.scene.Parent;
      import javafx.scene.Scene;
      import javafx.stage.Stage;
       
      /**
       *
       * @author herudi-pc
       */
      public class ListPlayer extends Application {
           
          @Override
          public void start(Stage stage) throws Exception {
              Parent root = FXMLLoader.load(getClass().getResource("/listplayer/view/masterListPlayer.fxml"));
              Scene scene = new Scene(root);
              stage.setScene(scene);
              stage.setTitle("List Player's 2014");
              stage.show();
          }
       
          /**
           * @param args the command line arguments
           */
          public static void main(String[] args) {
              launch(args);
          }
           
      }
      /*
       * To change this license header, choose License Headers in Project Properties.
       * To change this template file, choose Tools | Templates
       * and open the template in the editor.
       */
      package listplayer;
      
      import javafx.application.Application;
      import javafx.fxml.FXMLLoader;
      import javafx.scene.Parent;
      import javafx.scene.Scene;
      import javafx.stage.Stage;
      
      /**
       *
       * @author herudi-pc
       */
      public class ListPlayer extends Application {
          
          @Override
          public void start(Stage stage) throws Exception {
              Parent root = FXMLLoader.load(getClass().getResource("/listplayer/view/masterListPlayer.fxml"));
              Scene scene = new Scene(root);
              stage.setScene(scene);
              stage.setTitle("List Player's 2014");
              stage.show();
          }
      
          /**
           * @param args the command line arguments
           */
          public static void main(String[] args) {
              launch(args);
          }
          
      }
      

    akhirnya selesai juga tutorialnya, dan semoga bisa membantu agan dan aganwati sekalian. bila ingin ditanyakan tanyakanlah. Happy Coding Day. :)

    *bila ingin projectnya silahkan follow dan PM ke twitter ane @herudi45.