SWING / CATATAN</>↗Swing04 Nov 2008
To create a JLabel with an image icon we can either pass an ImageIcon as a second parameter to the JLabel constructor or use the JLabel.setIcon() method to set the icon. package org.kodejava.swing; import javax.swing.*; import java.awt.*; import java.util.Objects; public class JLabelWithIcon extends JFrame { public JLabelWithIcon() throws HeadlessException { initialize(); } private void initialize() […]
SWING / CATATAN</>↗Swing30 Okt 2008
package org.kodejava.swing; import javax.swing.*; import java.awt.*; public class JLabelDemo extends JFrame { public JLabelDemo() throws HeadlessException { initialize(); } private void initialize() { setSize(150, 300); setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); setLayout(new FlowLayout()); // Create some JLabel with Texts and define the horizontal alignment JLabel label1 = new JLabel("Username :", JLabel.RIGHT); JLabel label2 = new JLabel("Password :", JLabel.R...
HIBERNATE / CATATAN</>↗Hibernate26 Okt 2008
The code below demonstration the use of Projections.min(), Projections.max(), Projections.avg() and Projections.sum(). package org.kodejava.hibernate; import org.hibernate.SessionFactory; import org.hibernate.Session; import org.hibernate.HibernateException; import org.hibernate.Criteria; import org.hibernate.cfg.Configuration; import org.hibernate.criterion.Projections; import org.kodejava.hibernate.model.Track; public class MinMaxAvgSumProjectionsDemo { public static Sessio...
HIBERNATE / CATATAN</>↗Hibernate25 Okt 2008
The Criteria.uniqueResult() method make it easier to query a single instance of a persistence object. When no persistence found this method will return a null value. package org.kodejava.hibernate; import org.hibernate.Criteria; import org.hibernate.HibernateException; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.cfg.Configuration; import org.hibernate.criterion.Restrictions; import org.kodejava.hibernate.model.Genre; public class Un...
HIBERNATE / CATATAN</>↗Hibernate21 Okt 2008
o set the fetching mode for association we can call the Criteria‘s setFetchMode() method. We can use the FetchMode.SELECT or FetchMode.JOIN. package org.kodejava.hibernate; import org.hibernate.*; import org.hibernate.cfg.Configuration; import org.hibernate.criterion.Restrictions; import org.kodejava.hibernate.model.Record; import java.util.List; public class FetchModeDemo { public static Session getSession() throws HibernateException { String cfg = "hibernate.cfg.xml"; Sessi...
HIBERNATE / CATATAN</>↗Hibernate20 Okt 2008
The example below show how to get total row count using the Projections.rowCount(). The result of this query will be a single object of Integer that contains the result of executing an SQL select count (*) command. package org.kodejava.hibernate; import org.hibernate.SessionFactory; import org.hibernate.Session; import org.hibernate.HibernateException; import org.hibernate.Criteria; import org.hibernate.cfg.Configuration; import org.hibernate.criterion.Projections; import org...