In this part I will show how to define the repository and controller Java classes for our Pet class. This part assumes you have completed Part 3 of this series of articles. In the previous part we defined a Pet class and made it suitable to become a database table. We now need a repository class that forms the data access mechanism....
Normally when installing NetBeans, and most other IDEs, you need to already have a Java Development Kit (JDK) installed on your device. It is sometimes useful to be able to install NetBeans together with the latest JDK for the following reasons: > To make installation easier and more convenient.> To use the latest JDK that won't interfere wit...
Method delegation in Java In this article I will show how you can delegate a method call from one Java object to another. Let's start with a simple Employee class that contains a method to perform some work: public class Employee { public void performSomeWork() { System.out.println("I am performing some work); }} Now suppose we have a Business clas...
Using the static keyword in Java to increment an object index number In this article I will show how to use Java's static keyword to increment a unique index number for object instances. We will start by creating a simple class called Employee comprising fields only for name and address. These fields will be normal instance variables: public class ...
Previous lesson: 20.3 JavaBeansCourse contents Networking Two of the main ways of programming networking applications in Java is through sockets and Remote Method Invocation (RMI): Sockets Java supports connection to other hosts through the use of sockets. You can use the Socket class (in package java.net) to connect to a remote host b...
Previous lesson: 20.2 GraphicsCourse contents JavaBeans A JavaBean is a reusable component that is written to conform to certain conventions. Although they don't have to be, JavaBeans are often graphical in nature and in fact all the Swing graphical components are JavaBeans. This enables them to be used within builder tools such as NetBeans. ...
Previous lesson: 20.1 Other Java featuresCourse contents Graphics There are facilities to draw graphics by overriding the paint() method of the component classes. Create a new class in virtualzoo.ui called PenguinPicture: package virtualzoo.ui;import java.awt.*;import javax.swing.*;public class PenguinPicture extends JPanel { @Override public void ...
Previous lesson: 19.2 Other types of persistenceCourse contents Other Java features The desktop application developed in this course used many, but not all, of the major facilities of the Java language. This final section provides a brief look at some of the other useful features. In this section you will learn: How you can distribute your ap...
Previous lesson: 19.1 PersistenceCourse contents Other types of persistence You have seen how object serialization provides a relatively straightforward mechanism for saving the contents of one or more objects to a disk file. This section briefly mentions a few other ways in which data of various sorts can be saved to files. Saving individual...
Previous lesson: 18.4 Setting the look and feelCourse contents Persistence Many applications are only of limited use if they are not able to save their state each time they run. Persistence enables you to store information to disk and to read it back at a later time. In this section you will learn: How to save data to a disk fileHow to read s...