Practical Example of MVC Java Swing With Netbeans
Practical Example of MVC Java Swing With Netbeans
Subject Programming
Model View Controller (MVC) is a software architecture pattern that separates
the data of an application, the user interface, and the business logic in three
distinct components.(According to Saint Wikipedia)
A bit of theory.
Model: This is the specific representation of the information with which the system operates. Also
it is the one that interacts directly with the database
View: This presents the model in a suitable format to interact with the system, usually
the user interface.
Controller: This responds to events, usually user actions, and invokes requests to the
model and, probably, in view.
Flow that follows the implementation of this model.
1. The User interacts with the system through the User Interface (GUI) for example
pressing buttons, entering text, moving the mouse around the screen, etc.
2. The Controller is the one that receives all these actions caused by the User interaction.
Interface and act accordingly, "If Event X then perform Action Y."
3. The controller then accesses the Model to perform an action depending on the requested event.
update (registration, editing or deletion of information) in the database or request
information (a query for example).
4. The information is processed in a controlled model and it is the controller responsible for
generate an output for the user (Error message if a problem occurred, update of
information present on screen or generate a new screen.
5. Then the User Interface (View) is once again waiting for an action from the user.
system to repeat the cycle again.
So far so good, this is the summarized theory.I hope you are well.of what a Pattern is
MVC (Model, View and Controller) but nothing is theory if we do not put it into practice.
Practice, however I must say that the MVC pattern is more common in applications.
web than in desktop applications, searching for information on the internet are
few and the vast majority information in English(without drawings ) about applications
Swing-Java, but that doesn't mean it can't be done; it can be done, and it's more Java.
has its own tools to implement this pattern (Observer and
(Observable) but for this project I decided to base it more on a PHP-MVC model.
what I have, in which the migration is not very complicated since both work
under OOP.
Tools used. The following technologies were used:
IDE Netbeans 6.9
A MySQL Database Server
Libraries for report management (JasperReport v3.7.2)
commons-beanutils-1.8.2.jar
commons-collections-3.2.1.jar
- commons-digester-1.7.jar
commons-javaflow-20060411.jar
commons-logging-1.1.jar
groovy-all-1.5.5.jar
iText-2.1.7.jar
jasperreports-3.7.2.jar
*.JAR connector for Java and MySQL
mysql-connector-java-5.1.6-bin.jar
Libraries for user interface design (These libraries are written by me and are in the
Web/Blog
- j2Button.jar: For the handling of multiline buttons
- JCDesktopPane.jar: To work with MDI forms and with a background image.
- jcMousePanel-1.6.9.jar: To add images and gradient to the JPanel.
- jcTablaAsignatura.jar: This component simulates a small table for work.
with the database information.
All these libraries are included in the download file at the bottom of the page.
A report designer JaspertReport or you can also use the plugin for Netbeans.
What do you need to know?
Intermediate-Advanced Java
MySql Language
Use of Netbeans, the IDE we use for the project (adding libraries, changing properties, etc.)
Use of JasperReport
What do I expect from you?
First, make sure you like the project and learn from it.
That you make constructive criticisms, I don't know everything and I make mistakes, but we learn from errors.
If the project helped you, recommend it.
THE PROJECT
The chosen project for the implementation of the MVC-Java Pattern is the
Program of Subjects of an Imaginary University with the printing of
their respective enrollment.
When starting the system, you must authenticate by providing your CU (University Card) and your CI.
(Identity card), once logged into the system you must schedule yourself, if you are already
scheduled, the system does not allow you to schedule yourself twice, you can only see your
registration and print it, otherwise the system shows you
una lista de 8 asignaturas con sus respectivos grupos, los cuales puedes seleccionar
and program. But it's better to watch the following video so everything becomes clearer for you.