Spring 4, Hibernate 4 on JavaFX
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:
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. :(
- 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>
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; } }
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>
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; } }
- Silahkan klik add spring framework, library nya sudah disediakan di netbenas.
- jangan lupa beri nama.
- Source appConfig.xml
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 | <? xml version = "1.0" encoding = "UTF-8" ?> xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.0.xsd http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms-4.0.xsd http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-4.0.xsd http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi-1.2.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd "> < context:component-scan base-package = "listplayer.implement" /> < tx:annotation-driven transaction-manager = "transactionManager" /> < context:property-placeholder location = "classpath:jdbc.properties" /> < bean id = "dataSource" class = "org.springframework.jdbc.datasource.DriverManagerDataSource" > < property name = "driverClassName" value = "${jdbc.driver}" /> < property name = "url" value = "${jdbc.url}" /> < property name = "username" value = "${jdbc.username}" /> < property name = "password" value = "${jdbc.password}" /> </ bean > < bean id = "sessionFactory" class = "org.springframework.orm.hibernate4.LocalSessionFactoryBean" > < property name = "dataSource" ref = "dataSource" /> < property name = "configLocation" value = "classpath:hibernate.cfg.xml" /> </ bean > < bean id = "transactionManager" class = "org.springframework.orm.hibernate4.HibernateTransactionManager" > < property name = "sessionFactory" ref = "sessionFactory" /> </ bean > </ beans > |
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:c="http://www.springframework.org/schema/c" xmlns:context="http://www.springframework.org/schema/context" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:jms="http://www.springframework.org/schema/jms" xmlns:lang="http://www.springframework.org/schema/lang" xmlns:osgi="http://www.springframework.org/schema/osgi" xmlns:p="http://www.springframework.org/schema/p" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.0.xsd http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms-4.0.xsd http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-4.0.xsd http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi-1.2.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd "> <context:component-scan base-package="listplayer.implement"/> <tx:annotation-driven transaction-manager="transactionManager"/> <context:property-placeholder location="classpath:jdbc.properties"/> <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="${jdbc.driver}" /> <property name="url" value="${jdbc.url}" /> <property name="username" value="${jdbc.username}" /> <property name="password" value="${jdbc.password}" /> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"> <property name="dataSource" ref="dataSource"/> <property name="configLocation" value="classpath:hibernate.cfg.xml"/> </bean> <bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory"/> </bean> </beans>
- 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(); } }
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); }
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); }
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(); } }
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(); } }
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(); } }
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) { } } }
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; } }
- 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(); } }
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 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-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 ; } |
/* 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; }
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; }
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.
- source club.fxml Klik Disini club.fxml.
- Package listplayer.controller nama class masterListPlayerController.java Klik Disini masterListPlayerController.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.
Langganan:
Posting Komentar
(
Atom
)
not download player.fxml, masterList.... link die TT
BalasHapuserror while loading...
BalasHapus