Implementierung einer GUI-Applikation zur optimalen Zuordnung von Studenten mittels Java/Swing

Bachelor Thesis, 2008

47 Pages, Grade: 1



1 Project description of JAssign
1.1 Introduction
1.2 System specifications
1.3 Available legacy systems and resources
1.4 Project schedule
1.5 Project Milestones
1.6 Structured plan

2 Creation of a GUI with Java / Swing
2.1 Basic description of Swing
2.2 Commonly used widgets

3 Implementation
3.1 The class structure of JAssign
3.2 External libraries used
3.3 The datatype package
3.4 The functions package
3.5 The optimization package
3.6 The user interface

4 Conclusion

5 Appendix
5.1 The optimization model used

List of Figures

1.1 Use-cases of JAssign
1.2 Structured plan

2.1 Component hierarchy of Swing, Source: (Sun Microsystems, 2008a)

3.1 The data model used in JAssign
3.2 Screenshot of JAssign showing the Welcome tab
3.3 Screenshot of JAssign showing the Import tab
3.4 Screenshot of JAssign showing the Students tab
3.5 Screenshot of JAssign showing the Preferences tab
3.6 Screenshot of JAssign showing the Projects tab
3.7 Screenshot of JAssign showing the Categories tab
3.8 Screenshot of JAssign showing the Optimization Settings tab
3.9 Screenshot of JAssign showing the Results tab

1 Project description of JAssign

1.1 Introduction

In some university courses several topics exist for the participants to choose from. Almost certainly, if the number of topics is smaller than the num­ber of participating students, problems about matching each student with a topic will arise. If students are given the possibility to rank the available topics freely by assigning numerical preferences and working in groups is also permitted or even mandatory, the process of assigning is prone to lead to a clash of interests. The possibility of randomly assigning the participants is likely to yield even less satisfactory results and will ignore the individual preferences. Additionally, if upper and lower boundaries for the number of students in each group exist, the question of allocation becomes even more complex. The process of group-building and assigning the participants to different projects with an emphasis on their preference can be done manu­ally with the help of pen and paper, which is a tedious and time-consuming task and makes the use of an application to solve this problem reasonable. Strictly mathematically speaking this is a problem of linear optimization which can be solved efficiently following known algorithms. The aim of this project is the development of a Java application with a graphical user in­terface, based on the Swing toolkit distributed with Java, that provides the functionality to assign students to groups according to their preferences.

An implementation of a similar application with a similar functional scope already exists, the main differences arise from the choice of platform and technology. The predecessor is a Java-EE (Java Enterprise Edition) appli­cation which was developed for a web context and employs technologies es­pecially created for the purpose of fostering web-based, location-independent applications. The system operates on a client-server architecture and uses a role-based access model which incorporates individual views for students, lecturers and admins, including extensive help. To provide efficient data handling a relational DBMS is used. This system is fully documented and will be an available reference throughout the development of JAssign. A spreadsheet-based version written in Excel additionally exists which also deals with the specified allocation problem.

1.2 System specifications

Basic functionality

- Stand-alone architecture that does not require network access.
- Usage of technological framework of Java and the JDK.
- Runs inside a Java Runtime Environment which makes the application basically platform independent, a feature that is one of the hallmarks of Java.
- Graphical components employ and follow the standards of the Java Swing Framework, a collection of classes especially designed for the creation of graphical user interfaces. Regarding alignment and design of the widgets, the GUI shall be easy to use and intuitive in terms of usability.
- Provides the necessary functions to allow users to import or export data used for the internal assignment process in a widespread and commonly used plaintext format. Importing and exporting to CSV (Comma sep­arated values) is supported.
- The results of the optimization process are displayed in a formatted and presentable view that is suited for printing. To accomplish this, a fea­ture that allows exporting to a newly created PDF file is implemented.
- The usePs interaction with the application is conducted over a graphical user interface (GUI) which provides commonly used widgets and visual elements that conceal the complexity of the real application and offer the user convenient means to interact with the program.
- The language used throughout the application and auxiliary documen­tation will be English.
- An extensive help feature which mainly uses tooltips facilitates user interaction.
- External libraries are used to provide highly complex functions which would be extremely intricate to develop. These libraries are included and harnessed under the terms and conditions of their licenses.

— The library lp_solve, which is publicly available under the LGPL (Lesser GNU Public License) is used for problems pertaining to linear optimization.

— The Java library iText offers convenient methods to create and write a pdf document from within Java and is used for exporting the formatted results to PDF.

- Architecture and design of the application are implemented on a mod­ular basis to allow further extension.


This section describes the logical and functional interactions from the user perspective. As this is a standalone-application, the creation of different roles and perspectives is not required. The usePs perspective is generally expected to be the role of the lecturer whose main concern is the assignment of the participants to the tendered topics. Figure 1.1 shows a use-case diagram. The user can:

- specify an external file (csv) as source of the data to be imported. Addi­tionally the number of lines to be skipped and the separation character which denotes the position of an entry inside the csv-file can be defined.
- modify the imported or inserted data in a convenient way.
- create and modify the projects (topics) that are available for distribu­tion.
- specify the minimal and maximal number of participants for each project in advance.
- alter the given preferences and modify the results of the optimization process by changing the assignment.
- specify categories which serve as constraints and ensure a projects is or is not assigned to particular students.

Abbildung in dieser Leseprobe nicht enthalten

Figure 1.1: Use-eases of JAssign

- influence the optimization process in advance by specifying constraints and parameters for each student and project.

1.3 Available legacy systems and resources

OptAssign is a Java-EE based application for assigning students to topics within university courses (Waglechner, 2008). Its core functionality shall be sketched to briefly show its features and outline the functional connection to JAssign. OptAssign employs a MySQL-based database which is integrated with the help of the Java Persistence API. The external library lp_solve provides a wrapper for Java and is used for solving the problem of optimiza­tion which is done by translating it into a linear model. Using a server-client architecture, OptAssign provides a web-based interface for access, which is based on a role model that allows several types of users with different per­missions to perform the actions typical for their role. Three types of roles are intended: Administrator for general administration of the assembled data and registered users, Course Lecturer to create and delete courses, admit students and execute the optimization process in order to assign these stu­dents to a particular course. A user of the role Student can rank the projects available for distribution by assigning individual preferences to them.

The core optimization model takes each student’s preferences into account upon calculating the optimal assignment of these students to the tendered projects.

OptAssign shares the core of the optimization feature and some of the use- cases with JAssign. The core of the optimization feature of OptAssign will be adapted to suit the data and technology of JAssign and thus serve as a reference, everything else will have to ]be developed from ground-up. An in-depth description of the mathematical optimization model is included in the Appendix.

1.4 Project schedule

Project aims

- Development of a standalone application optimally assigning students to projects in university courses.
- Testing the application in a productive environment and ensure it runs inside the JRE on Windows and Linux.
- Writing a complete documentation.


- Extending the web-based application.

- Add other languages apart from English or provide an architecture for multilingual extensions.
- Checking data for corruption or logical faults on import.
- Data maintenance or data collection.
- Extending and maintaining the final application after completion of the functional product.

1.5 Project Milestones

Abbildung in dieser Leseprobe nicht enthalten

Table 1.1: Project Milestones

1.6 Structured plan

Abbildung in dieser Leseprobe nicht enthalten

Figure 1,2: Structured plan

2 Creation of a GUI with Java / Swing

2.1 Basic description of Swing

Specially designed for the purpose of creating graphical user interfaces, the Java Foundation Classes were conceived to provide a framework and offer abundant features for interactivity and graphical display. The JFC classes consist of several different components that are closely intertwined to provide the functionality of a fully-fledged GUI. The following section will focus only on the Swing GUI components which are vital building blocks of every Java-based graphical application. Swing is the successor of Java's Abstract Window Toolkit, an earlier implementation of user interface components, however, it still makes use of AWT components to some extent.

Additionally, a framework for creating applications exists. The Swing Appli­cation Framework is a set of Java classes helping to design applications by providing designs that are common to typical applications and can be reused. “The Swing Application Framework is a light framework that simplifies the creation and maintaining of small- to medium-sized Java desktop applica­tions” (Sun Microsystems, 2008d). Java Specification Request 296 defines it as “...will provide a simple application framework for Swing applications. It will define infrastructure common to most desktop applications. In so doing, Swing applications will be easier to create” (Sun Microsystems, 2006).

The Swing classes provide elements that can be arranged and aligned in a desired order to serve as a graphical user interface. These components are predefined to a certain extent and can be regarded as general templates, yet they are highly customizable. Most components include predefined features such as sorting or drag and drop. The functionality of Swing is not limited to providing a collection of widgets, as a complete toolkit it also includes fea­tures such as event handling and window management. Swing components

Abbildung in dieser Leseprobe nicht enthalten

were designed to work the same on all platforms, to the maximum possible (Sun Microsystems, 2008c). Some of the more important compo­nents which have been used for the development of this application shall be described in the following sections.

The design of Swing components needs to adhere strictly to a predefined containment hierarchy, which can be regarded as a tree of all components displaying onscreen. A top-level container serves as provider of a content pane, which then contains the visible, non-menu elements. In a standalone Jam-application this role is usually assumed by a JFrame, in applets a JAp- plet component can serve as root. Additionally, a menu bar can be inserted into the top-level frame to include the functionality of a typical menu. Each program that uses Swing components has at least one top-level container and a component hierarchy, but also multiple are possible if more than one top-level container is implemented (Sun Microsystems, 2008a).

Elements can be directly added to the content pane, an example to accom- lìs is the following method:

. getContentPaneO.add(mybutton, BorderLayout.CENTER);

Here the second parameter specifies the layout manager to be used, defining the way in which the added components are to be aligned. Several layouts exist and Java tries to evaluate the position of the element preceding this parameter. However, the clear alignment of the different elements is not easily achieved, so the layout parameters have to be handled carefully.

Top-level containers should not be confused with the root pane, another intermediate container which manages the content pane and the menu bar. The presence of root panes is usually negligible for the typical developer, it can, however, be useful if intercepting mouse clicks or actions extending over multiple components is desired (Sun Microsystems, 2008a).

NetBeans IDE The integrated development environment NetBeans IDE has several features which greatly facilitate the creation of a GUI or any Java application. NetBeans includes several GUI Tools for the creation of sophis­ticated GUIs. Especially the GUI Builder (code named project Matisse), which was introduced in version 5.0 of the IDE, was designed to assist the developer in designing and building Java forms (Sun Microsystems, 2008b). Aligning the components of a GUI manually is challenging and prone to er­rors as the outcome can only be seen upon compiling, the GUI Builder of NetBeans does not only show a realistic preview but also allows editing and placing these components by drag and drop. This also applies to the po­sitioning of the elements, thus ensuring the usehs alignment is maintained. “The GUI Builder enables you to lay out forms by placing components where you want them and by providing visual feedback in the form of guidelines” (Sun Microsystems, 2008d). Its automatic code generation feature embeds the GUI into Java code, concealing the complexity of the components5 gen­eration and arrangement, which allows the developer to focus on the applica­tion logic. The code generated by the GUI Builder is highlighted as Guarded Block, making it not directly editable.

The Swing Application Framework

NetBeans is designed to fully support the Swing Application Framework, which can serve as a template for building Swing-based applications. “The framework’s primary goal is to provide the kernel of a typical Swing applica­tion, helping programmers to get started quickly and to adopt best practices for just a few elements common to every Swing application: architecture, lifecycle, resource management, event handling, threading, session state, and local storage” (O’Conner, 2007). Basically, two classes exist to help manag­ing an application: Application and ApplicationContext, with a 1:1 rela­tionship between them. ApplicationContext provides services to the appli­cation. Programs using the Swing Application Framework must extend the Application class or its SingleFrameApplication subclass. Application provides lifecycle methods for launching the application, initializing the user interface and shutting down. SingleFrameApplication adds a default main GUI frame, retrieves and injects default resources, and uses the Application- Context to save and restore simple session state (O’Conner, 2007). The framework also handles resources such as icons, font definitions and text and supports multiple locales which makes translations to other languages easy. Resources are stored for each class in a file with a .properties suffix.

2.2 Commonly used widgets

In the Swing class hierarchy the name of many components starts with the letter J, which indicates that they descend from the JComponent class. That implies that all widgets, like JButton, JTable, JTextField inherit methods from their superclass JComponent, which extends the Container class, which itself extends the class Component. A variety of features is provided by the Component class: “The Component class includes everything from providing layout hints to supporting painting and events. The Container class has support for adding components to the container and laying them out” (Sun Microsystems, 2008a).

JComponent also provides a large variety of features such as:

- Tool tips: The simplest but must effective way of providing help to the user about a component. When the mouse pointer hovers over a component for a brief period of time, a small popup text appears near the component.


Excerpt out of 47 pages


Implementierung einer GUI-Applikation zur optimalen Zuordnung von Studenten mittels Java/Swing
University of Vienna  (Information Systems)
Catalog Number
ISBN (eBook)
ISBN (Book)
File size
2541 KB
Java, Swing, GUI, linear optimization, student allocation
Quote paper
MSc Markus Moser (Author), 2008, Implementierung einer GUI-Applikation zur optimalen Zuordnung von Studenten mittels Java/Swing , Munich, GRIN Verlag,


  • No comments yet.
Read the ebook
Title: Implementierung einer GUI-Applikation zur optimalen Zuordnung von Studenten mittels Java/Swing

Upload papers

Your term paper / thesis:

- Publication as eBook and book
- High royalties for the sales
- Completely free - with ISBN
- It only takes five minutes
- Every paper finds readers

Publish now - it's free