In the previous lesson we looked at containers and JPanel. Previous lesson: 13.2 Containers and JPanelCourse contents Using Inner classes Most classes you write are top-level classes, that is, independent classes in its own right and in their own class file. It is often useful to create inner classes, being classes that exist inside of anothe...
In the previous lesson we introduced graphical user interfaces. Previous lesson: 13.1 Graphical user interfacesCourse contents Containers and JPanel Because the Container object can contain other components, including other containers, it is possible to create some very sophisticated layouts. Rather than place your components directly onto a frame,...
The previous lesson discussed thread waiting and notification. Previous lesson: 12.4 Thread waiting and notificationCourse contents Graphical user interfaces A Graphical User Interface provides the primary means by which users of your application interact with it. In this section you will learn: The structure of graphical programsSome common ...
In the previous lesson you saw how to implement the Runnable interface. Previous lesson: 12.3 Implementing the Runnable interfaceCourse contents Thread waiting and notification For some types of multithreaded application, using the synchronized keyword alone is not enough on its own. Imagine that at the zoo the penguins are fed fish from a ba...
In the previous lesson we showed how to extend the Thread class. Previous lesson: 12.2 Extending the Thread classCourse contents Implementing the Runnable interface You have seen that you can extend the Thread class to define a class which can run concurrently with other threads, but what if the class you want to make multithreaded already extends ...
In the previous lesson we learnt about the concepts of multithreading. Previous lesson: 12.2 MultithreadingCourse contents Extending the Thread class The first way of defining a multithreaded class is to extend the Thread class and override its run() method. Here is the Booker class which does just that: package virtualzoo.core;public class Booker ...
In the previous lesson we saw how to use Map. Previous lesson: 11.4 using MapCourse contents Multithreading Threads allow your application to perform more than one process concurrently. In this section you will learn: The principles of multi-threadingExtending the Thread classImplementing the Runnable interfaceUsing wait() and notifyAll() to ...
In the previous lesson we looked an maps. Previous lesson: 11.3 MapsCourse contents Using a Map for zookeeper's responsibilities At the zoo, each zookeeper is responsible for certain pens, as listed below: Alice looks after the monkeys and penguinsBob looks after the lions, monkeys and penguinsCharles only looks after the penguins This can be...
In the previous lesson we used our Pen class in ZooAdministrator. Previous lesson: 11.2 Using Pen in ZooAdministratorCourse contents Maps You can think of a Map as being like a dictionary – you can look up a word to find its definition. But maps in Java are much more flexible than that since you can use them to look up any object to fin...
In the previous lesson we looked at lists and set. Previous lesson: 11.1 Lists and SetsCourse contents Using the Pen class in ZooAdministrator The zoo administrator will keep a record of each pen in the zoo, being one for each of the animal types. In the ZooAdministrator class define these Pen instance variables: private Pen lionPen, monkeyPe...