HIBERNATE / NOTES</>↗Hibernate12 Oct 2008
To create a pagination or limit the result set returned by the Criteria query we can use the setFirstResult() and setMaxResults() method. The setFirstResult() method defines the first row to start with and the setMaxResults() method defines the maximum number of records to read. Let’s see the demo below. package org.kodejava.hibernate; import org.hibernate.SessionFactory; import org.hibernate.Session; […]
HIBERNATE / NOTES</>↗Hibernate07 Oct 2008
This example show you how to create an instance of Hibernate Criteria class. To create a Criteria we call the factory method of the Session object and pass the persistence class as parameter. To execute the Criteria query we simply call the list() method. package org.kodejava.hibernate; import org.hibernate.SessionFactory; import org.hibernate.Session; import org.hibernate.HibernateException; import org.hibernate.Criteria; import […]
SWING / NOTES</>↗Swing05 Oct 2008
This example demonstrate how to create a message dialog box using the JOptionPane class methods. In the code below you’ll see the use of JOptionPane.showMessageDialog(), JOptionPane.showInputDialog() and JOptionPane.showConfirmDialog(). package org.kodejava.swing; import javax.swing.*; import java.awt.*; public class MessageDialogDemo extends JFrame { public MessageDialogDemo() throws HeadlessException { initialize(); } public static void main(String[] args) { SwingUtilities....
CORE API / NOTES</>↗Core API03 Oct 2008
This example demonstrate how to execute an external command from Java and obtain the result of the command. Here we simply execute a Linux ls -al command on the current working directory and display the result. package org.kodejava.lang; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; public class ProcessResult { public static void main(String[] args) { try […]
SWING / NOTES</>↗Swing01 Oct 2008
This code snippet gives an example on how to get the JFrame of a component. In this example we try to get the JFrame from a button action listener event. To get the JFrame we utilize the SwingUtilities.getRoot() method and this will return the root component of the component tree in out small program below […]
SWING / NOTES</>↗Swing30 Sep 2008
To disable the close operation on a JFrame, when user click the close icon on the JFrame, we can set the value of the default close operation to WindowConstants.DO_NOTHING_ON_CLOSE. package org.kodejava.swing; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.SwingUtilities; import javax.swing.WindowConstants; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.HeadlessException; public class DisableCloseButtonDemo extends JFrame { p...