A Pagination-enabled List in Swing with Hessian

In an ealier post I documented how to set up a maven project to use port 80 for client-server-communication in a Java Swing project.

Today I want to show how you could implement a list which shows ‘all’ objects of one entity. It is common that there exists thousand or more objects for one entity in a database, so pagination is required. I know that JList and JTable could handle very large result sets easily, but the bandwith would be the limitating factor and loading all the objects into memory is often not required (and not good …).

I will use the simplest Swing solution with some pagination buttons, although it would be a lot nicer to have the pagination with a custom vertical JScrollBar-implementation which loads the objects while scrolling (‘on demand’). But this will be either a task for my readers or for myself at a later time. First we can take a look at the resulting (primitive) GUI:


The interface for the data access object was quickly created:

public interface RemoteDao<T> {
   List<T> getAll(int index, int items, String query);
   int count(String query);

… the implementation, too (but for this see the source in the provided project). You can simply replace the existing fake-implementation with a RemoteHibernateDao or sth. like this, if you like.

The communication follows this picture:


To try this maven project: start PaginationServlet under the paginationlist package and then the PaginationClient. The Swing gui should pop up and you could hit enter after a search string like ‘person’ or ’18’ in the textfield at the top. Now try to paginate through the results with the provided buttons at the bottom.

The final goal for me (at a later time) will be to replace the left ‘Available’-JList in a ShuttleList (from Spring rich client project) with my PaginationList. For you information: with a normal ShuttleList one could drop one or more items from ‘available’ list to ‘choosen’ with the buttons in the middle (they have nothing to do with pagination!). Here a normal shuttle list is shown:


So, now have fun with my small Swing example and feel free to provide feedback or ask questions if you need help while maven or sth. else!


2 thoughts on “A Pagination-enabled List in Swing with Hessian

  1. Pingback: JTraining - Java Knowledge Community - Java Training

  2. Hi
    Its nice tosee this. Please can i get code of this. I have to present same like this only. Please send it to me. It will be very helpfull

Comments are closed.