user documentation

77
User Documentation Zach Stratenwerth ISE Java Unit 3 Video Store Project

Upload: zach-stratenwerth

Post on 18-Aug-2015

65 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: User Documentation

User Documentation

Zach Stratenwerth

ISE

Java Unit 3

Video Store Project

Page 2: User Documentation

Table of Content:

Page

Installation 1 Launching the application 1 Using the application 1-4 Source code 5-61

Page 3: User Documentation

Installation:

No installation is required, jar file runs program on execution. If you would like to create the jar file, the following instructions apply:

Right click on your project in NetBeans and hover over Configuration, then click on Customize.

In Project Properties, expand the Build option in the list, and then click on Packaging. Check both boxes and click OK. Right click on the project and click on clean and build. A dist folder should now have been added to your project folder. In the dist folder you will now be able to access the .jar file in each project.

Launching the application:

Open the Video Store Project folder. Open the MyServer folder. Open the dist folder. Double click the MyServer.jar file to execute the server app. Open the Video Store Project folder. Open the MyVideoStore folder. Open the dist folder. Double click the MyVideoStore.jar file to execute the video store app.

Using the application:

Firstly the user needs to run the server and connect to the server in order to gain access to the database.

Page 4: User Documentation

After that has taken place the user needs to start the video store app. Once they have done this they will see a loading screen go across the window as the

app prepares to launch.

On start up of the app , the user will see the user welcome message. Here they can navigate themselves around the app in order to either search through the available movies and genres , log in as an administrator , view the help menu or exit the app.

Page 5: User Documentation

If the user has chosen the Login as administrator button , a login frame will appear prompting the user for a username and password. The user will gain access with username: admin and password: password.

Once in the admin frame the user will see a welcome to admin interface message. In this interface the user will have all the same accessibility as the regular user as well as have the abilities to add and remove movies and add genres to the database.

In order for the admin user to view all the changes that they have made , one would need to click on the ‘Refresh’ button.

Page 6: User Documentation

They can view the ‘Help’ tab to gain more info about what they can do in the admin interface.

Once they have done everything they need they can either close/mimimize the app or logout and return to the normal users interface.

Page 7: User Documentation

Source code(Server):

MyServer package:

MyServer class:

/* * 2014/08/15 * Zach Stratenwerth * Video Store Project * Main Method used to run the server. */package myServer;

public class MyServer {

/** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(ServerGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(ServerGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(ServerGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(ServerGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //set the look and feel of the whole server to nimbus

new ServerGUI().setVisible(true); //run the main method

Page 8: User Documentation

//run the ServerGUI as visible }}ServerGUI class:/* * 2014/08/15 * Zach Stratenwerth * Video Store Project * Server GUI , design of the Server interface. */package myServer;

import java.awt.Color;import java.rmi.registry.LocateRegistry;import java.rmi.registry.Registry;import javax.swing.JOptionPane;import myServer.service.ServiceImpl;

public class ServerGUI extends javax.swing.JFrame {

/** * Creates new form ServerGUI */ public ServerGUI() { initComponents(); this.setLocationRelativeTo(null); //Initialize all the components and set the frame to the center }

public boolean stop() { boolean started = true;

try { Registry reg = LocateRegistry.createRegistry(1099); reg.rebind("VideoStore", new ServiceImpl()); //rebind and create a local registry connection started = false; } catch (Exception e) { e.printStackTrace(); started = true; } return started; } //create a stop method

public boolean start() { boolean started = false;

try { Registry reg = LocateRegistry.createRegistry(1099); reg.rebind("VideoStore", new ServiceImpl());

Page 9: User Documentation

//rebind and create a local registry connection started = true; } catch (Exception e) { e.printStackTrace(); started = false; } return started; } //create a start method

/** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() {

jButton1 = new javax.swing.JButton(); jLabel1 = new javax.swing.JLabel(); jButton2 = new javax.swing.JButton(); processLabel = new javax.swing.JLabel();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

jButton1.setText("Start!"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } });

jLabel1.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N jLabel1.setText("Video Store Server");

jButton2.setText("Stop!"); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); } });

processLabel.setFont(new java.awt.Font("Tahoma", 0, 15)); // NOI18N processLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

Page 10: User Documentation

.addComponent(processLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(113, 113, 113) .addComponent(jLabel1)) .addGroup(layout.createSequentialGroup() .addGap(147, 147, 147) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)))) .addContainerGap(120, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(49, 49, 49) .addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 48, Short.MAX_VALUE) .addComponent(processLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)) );

pack(); }// </editor-fold>

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: int closer = JOptionPane.showConfirmDialog(null, "Are you sure you want to shutdown server", "Confirm", JOptionPane.YES_NO_OPTION); if (closer == JOptionPane.YES_OPTION) { processLabel.setText("Stopped succesfully"); processLabel.setForeground(Color.ORANGE); System.exit(0); } else { } //create actions for the button to stop the server //create a check JOptionPane confirm dialog }

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {

Page 11: User Documentation

// TODO add your handling code here: if (start()) { processLabel.setText("Started succesfully"); processLabel.setForeground(Color.green); } else { processLabel.setText("Error starting Server ... Please contact admin"); processLabel.setForeground(Color.red); } //create an if else to check if the server launches //create actions for the button to start the server }

/** * @param args the command line arguments */ public static void main(String args[]) { /* * Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* * If Nimbus (introduced in Java SE 6) is not available, stay with the * default look and feel. For details see * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(ServerGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(ServerGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(ServerGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(ServerGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold>

Page 12: User Documentation

/* * Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new ServerGUI().setVisible(true); //Create the main method that runs a new instance of the ServerGUI and sets it to visible } }); } // Variables declaration - do not modify private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JLabel jLabel1; private javax.swing.JLabel processLabel; // End of variables declaration }ServerBeans package:Genre class:/* * 2014/08/15 * Zach Stratenwerth * Video Store Project * Genre bean, used to get and set all genre variables. */package myServer.ServerBeans;

import java.io.Serializable;

/** * * @author zach */public class Genre implements Serializable {

private int genreId; private String genreName;

public int getGenreId() { return genreId; }

public void setGenreId(int genreId) { this.genreId = genreId; }

public String getGenreName() { return genreName; }

Page 13: User Documentation

public void setGenreName(String genreName) { this.genreName = genreName; } //Create all required getters and setters}Movie class:/* * 2014/08/15 * Zach Stratenwerth * Video Store Project * Movie bean, used to get and set all movie variables. */package myServer.ServerBeans;

import java.io.Serializable;

/** * * @author zach */public class Movies implements Serializable {

private int movieId; private String movieName; private String desc; private int genreId; private Genre genre;

public String getDesc() { return desc; }

public void setDesc(String desc) { this.desc = desc; }

public int getGenreId() { return genreId; }

public void setGenreId(int genreId) { this.genreId = genreId; }

public int getMovieId() { return movieId; }

public void setMovieId(int movieId) { this.movieId = movieId; }

Page 14: User Documentation

public String getMovieName() { return movieName; }

public void setMovieName(String movieName) { this.movieName = movieName; }

public Genre getGenre() { return genre; }

public void setGenre(Genre genre) { this.genre = genre; } //Create all required getters and setters}Users class:/* * 2014/08/15 * Zach Stratenwerth * Video Store Project * User bean, used to get and set all user variables. */package myServer.ServerBeans;

import java.io.Serializable;

/** * * @author zach */public class Users implements Serializable {

private int userId; private String userName; private String password;

public String getPassword() { return password; }

public void setPassword(String password) { this.password = password; }

public int getUserId() { return userId; }

Page 15: User Documentation

public void setUserId(int userId) { this.userId = userId; }

public String getUserName() { return userName; }

public void setUserName(String userName) { this.userName = userName; } //Create all required getters and setters}Service package:ServiceImpl class:/* * 2014/08/15 * Zach Stratenwerth * Video Store Project * Used to implement and create all the interfaces. */package myServer.service;

import java.rmi.RemoteException;import java.rmi.server.UnicastRemoteObject;import java.sql.*;import java.util.ArrayList;import java.util.logging.Level;import java.util.logging.Logger;import myServer.ServerBeans.Genre;import myServer.ServerBeans.Movies;

public class ServiceImpl extends UnicastRemoteObject implements ServiceInt {

static Connection connection = null; private Statement statement = null;

public static Connection getConnection() { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); connection = DriverManager.getConnection("jdbc:odbc:MovieDB"); } catch (Exception e) { System.out.println("Error " + e.getMessage()); } return connection; } //create and get a connection to the MovieDB database

void closeConnection() { try { connection.close();

Page 16: User Documentation

} catch (SQLException ex) { Logger.getLogger(ServiceImpl.class.getName()).log(Level.SEVERE, null, ex); } } //create a method to close the connection to the database

public ServiceImpl() throws RemoteException { }

public boolean checkLogin(String userName, String password) throws RemoteException { boolean access = false; System.out.println("looking " + password); try { getConnection(); statement = connection.createStatement();

String sql = "Select * from Users WHERE username = '" + userName + "' AND password = '" + password + "';"; ResultSet rs = statement.executeQuery(sql);

while (rs.next()) { access = true; } } catch (Exception e) { System.out.println(e); } finally { if (connection != null) { closeConnection(); } } return access; } //create a check login method that uses the sql statement to check ones login details and compare to the users in the database.

@Override public ArrayList<Movies> getAllMovies() throws RemoteException { ArrayList<Movies> movieList = new ArrayList<Movies>();

try { getConnection(); statement = connection.createStatement();

String sql = "Select A.movie_id, A.movie_name, A.description, A.genre_id, B.genre_name FROM Movies AS A, Genres AS B WHERE A.genre_id = B.genre_id;"; ResultSet rs = statement.executeQuery(sql);

while (rs.next()) { Movies movie = new Movies(); Genre genre = new Genre();

Page 17: User Documentation

movie.setMovieId(rs.getInt("movie_id")); movie.setMovieName(rs.getString("movie_name")); movie.setDesc(rs.getString("description")); movie.setGenreId(rs.getInt("genre_id")); genre.setGenreName(rs.getString("genre_name")); movie.setGenre(genre); movieList.add(movie);

} } catch (Exception e) { e.printStackTrace(); } finally { if (connection != null) { closeConnection(); } } return movieList; } //create method to fetch all the movie details from the database.

@Override public ArrayList<Movies> getMovieByName(String movieName) { ArrayList<Movies> movieList = new ArrayList<Movies>();

try { getConnection(); statement = connection.createStatement();

String sql = "Select A.movie_id, A.movie_name, A.description, A.genre_id, B.genre_name FROM Movies AS A, Genres AS B WHERE A.genre_id = B.genre_id AND A.movie_name LIKE '%" + movieName + "%';"; ResultSet rs = statement.executeQuery(sql);

while (rs.next()) { Movies movie = new Movies(); Genre genre = new Genre();

movie.setMovieId(rs.getInt("movie_id")); movie.setMovieName(rs.getString("movie_name")); movie.setDesc(rs.getString("description")); movie.setGenreId(rs.getInt("genre_id")); genre.setGenreName(rs.getString("genre_name")); movie.setGenre(genre); movieList.add(movie);

} } catch (Exception e) { e.printStackTrace(); } finally { if (connection != null) { closeConnection();

Page 18: User Documentation

} } return movieList; } //create method to fetch all the movie details by the movie name from the database.

@Override public ArrayList<Movies> getMovieByGenre(String genreName) { ArrayList<Movies> movieList = new ArrayList<Movies>();

try { getConnection(); statement = connection.createStatement();

String sql = "Select A.movie_id, A.movie_name, A.description, A.genre_id, B.genre_name FROM Movies AS A, Genres AS B WHERE A.genre_id = B.genre_id AND B.genre_name LIKE '%" + genreName + "%';"; ResultSet rs = statement.executeQuery(sql);

while (rs.next()) { Movies movie = new Movies(); Genre genre = new Genre();

movie.setMovieId(rs.getInt("movie_id")); movie.setMovieName(rs.getString("movie_name")); movie.setDesc(rs.getString("description")); movie.setGenreId(rs.getInt("genre_id")); genre.setGenreName(rs.getString("genre_name")); movie.setGenre(genre); movieList.add(movie);

} } catch (Exception e) { e.printStackTrace(); } finally { if (connection != null) { closeConnection(); } } return movieList; } //create method to fetch all the movie details by the genre name from the database.

public boolean addMovie(Movies movie) { boolean bool = false; try { getConnection(); statement = connection.createStatement();

String sql = "INSERT INTO Movies(movie_name,description,genre_id) VALUES('" + movie.getMovieName() + "','" + movie.getDesc() + "'," + movie.getGenreId() + ");";

Page 19: User Documentation

statement.executeUpdate(sql); bool = true; } catch (Exception e) { e.printStackTrace(); bool = false; } finally { if (connection != null) { closeConnection(); } } return bool; } //create method to insert a new movie into the database.

public boolean deleteMovie(int movieID) { ArrayList<Movies> movieList = new ArrayList<Movies>(); boolean bool = false; try { getConnection(); statement = connection.createStatement();

String sql = "DELETE FROM Movies WHERE movie_id =" + movieID + ";"; statement.executeUpdate(sql);

bool = true; } catch (Exception e) { e.printStackTrace(); bool = false; } finally { if (connection != null) { closeConnection(); } } return bool; } //create method to delete a movie from the database.

public ArrayList<Genre> getAllGenres() throws RemoteException { ArrayList<Genre> genreList = new ArrayList<Genre>();

try { getConnection(); statement = connection.createStatement();

String sql = "Select * FROM Genres ORDER BY genre_id ASC;"; ResultSet rs = statement.executeQuery(sql);

while (rs.next()) { Genre genre = new Genre(); genre.setGenreId(rs.getInt("genre_id")); genre.setGenreName(rs.getString("genre_name"));

Page 20: User Documentation

genreList.add(genre); } } catch (Exception e) { e.printStackTrace(); } finally { if (connection != null) { closeConnection(); } } return genreList; } //create method to fetch all the genre details from the database.

public boolean addGenre(Genre genre) throws RemoteException { boolean bool = false; try { getConnection(); statement = connection.createStatement();

String sql = "INSERT INTO Genres(genre_name) VALUES('" + genre.getGenreName() + "');"; statement.executeUpdate(sql); bool = true; } catch (Exception e) { e.printStackTrace(); bool = false; } finally { if (connection != null) { closeConnection(); } } return bool; } //create method to insert a new genre into the database.}ServiceInt class:* Zach Stratenwerth * Video Store Project * Used to call all the impelmentation through this interface. */package myServer.service;

import java.rmi.Remote;import java.rmi.RemoteException;import java.util.ArrayList;import myServer.ServerBeans.Genre;import myServer.ServerBeans.Movies;

public interface ServiceInt extends Remote {

public boolean checkLogin(String userName, String password) throws RemoteException;

Page 21: User Documentation

public ArrayList<Movies> getAllMovies() throws RemoteException;

public ArrayList<Movies> getMovieByName(String movieName) throws RemoteException;

public ArrayList<Movies> getMovieByGenre(String genreName) throws RemoteException;

public boolean addMovie(Movies movie) throws RemoteException;

public boolean deleteMovie(int movieID) throws RemoteException;

public ArrayList<Genre> getAllGenres() throws RemoteException;

public boolean addGenre(Genre genre) throws RemoteException;}//Creatation of all the required implementation interfaces

Source code(VideoStore):AdminGUI package:AddGenre class:/* * 2014/08/15 * Zach Stratenwerth * Video Store Project * Create the GUI for the add genre frame. */package adminGUI;

import java.rmi.RemoteException;import java.rmi.registry.LocateRegistry;import java.rmi.registry.Registry;import java.util.logging.Level;import java.util.logging.Logger;import javax.swing.JOptionPane;import myServer.ServerBeans.Genre;import myServer.service.ServiceInt;

public class AddGenre extends javax.swing.JFrame {

public ServiceInt myService = null;

private void doConnection() { try { Registry myRegistry = LocateRegistry.getRegistry("localhost", 1099); myService = (ServiceInt) myRegistry.lookup("VideoStore"); } catch (Exception e) { e.printStackTrace(); } }

/** * Creates new form AddMovie

Page 22: User Documentation

*/ public AddGenre() { initComponents(); this.setLocationRelativeTo(null); doConnection(); }

/** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() {

jLabel2 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); jTextField3 = new javax.swing.JTextField(); jButton1 = new javax.swing.JButton();

setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

jLabel2.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N jLabel2.setText("Add a new Genre!");

jLabel4.setText("Genre Name:");

jTextField3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jTextField3ActionPerformed(evt); } });

jButton1.setText("Add"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } });

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap(77, Short.MAX_VALUE) .addComponent(jLabel2) .addGap(68, 68, 68)) .addGroup(layout.createSequentialGroup() .addGap(18, 18, 18)

Page 23: User Documentation

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel4) .addGroup(layout.createSequentialGroup() .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jButton1))) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(10, 10, 10) .addComponent(jLabel2) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel4) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton1)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) );

pack(); }// </editor-fold>

private void jTextField3ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: }

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: String name = jTextField3.getText(); if (name == null || name.equals("")) { JOptionPane.showMessageDialog(null, "Please enter in a genre name."); } else { Genre gen = new Genre(); gen.setGenreName(name); try { if (myService.addGenre(gen)) { JOptionPane.showMessageDialog(null, "Genre Successfully added."); this.dispose(); } else { JOptionPane.showMessageDialog(null, "Genre Unsuccessfully added."); } } catch (RemoteException ex) { Logger.getLogger(AddGenre.class.getName()).log(Level.SEVERE, null, ex); } } //creat all the function to the add button and if statement fro the correct message

Page 24: User Documentation

}

/** * @param args the command line arguments */ public static void main(String args[]) { /* * Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* * If Nimbus (introduced in Java SE 6) is not available, stay with the * default look and feel. For details see * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(AddGenre.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(AddGenre.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(AddGenre.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(AddGenre.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold>

/* * Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new AddGenre().setVisible(true); } //run the main method });

Page 25: User Documentation

} // Variables declaration - do not modify private javax.swing.JButton jButton1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel4; private javax.swing.JTextField jTextField3; // End of variables declaration }AddMovie class:/* * 2014/08/15 * Zach Stratenwerth * Video Store Project * Create the GUI for the add movie frame. */package adminGUI;

import java.rmi.RemoteException;import java.rmi.registry.LocateRegistry;import java.rmi.registry.Registry;import java.util.ArrayList;import java.util.logging.Level;import java.util.logging.Logger;import javax.swing.JOptionPane;import myServer.ServerBeans.Genre;import myServer.ServerBeans.Movies;import myServer.service.ServiceInt;

public class AddMovie extends javax.swing.JFrame {

public ServiceInt myService = null;

private void doConnection() { try { Registry myRegistry = LocateRegistry.getRegistry("localhost", 1099); myService = (ServiceInt) myRegistry.lookup("VideoStore"); } catch (Exception e) { e.printStackTrace(); } } //run a new connection on the new GUI.

/** * Creates new form AddMovie */ void populateGenre() throws RemoteException { ArrayList<Genre> genreList = myService.getAllGenres(); for (Genre genre : genreList) { jComboBox1.addItem(genre.getGenreName()); } }

Page 26: User Documentation

//populate the genre combo box with the genres from the database

public AddMovie() { initComponents(); this.setLocationRelativeTo(null); doConnection(); try { populateGenre(); } catch (RemoteException ex) { Logger.getLogger(AddMovie.class.getName()).log(Level.SEVERE, null, ex); } } //Create and run the add movie method

/** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() {

jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jTextField2 = new javax.swing.JTextField(); jLabel4 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); jScrollPane1 = new javax.swing.JScrollPane(); jTextArea1 = new javax.swing.JTextArea(); jButton1 = new javax.swing.JButton(); jComboBox1 = new javax.swing.JComboBox();

setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

jLabel1.setText("Movie Name:");

jLabel2.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N jLabel2.setText("Add a new Movie!");

jTextField2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jTextField2ActionPerformed(evt); } });

jLabel4.setText("Genre Name:");

jLabel5.setText("Description:");

jTextArea1.setColumns(20);

Page 27: User Documentation

jTextArea1.setLineWrap(true); jTextArea1.setRows(5); jScrollPane1.setViewportView(jTextArea1);

jButton1.setText("Add"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } });

jComboBox1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jComboBox1ActionPerformed(evt); } });

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jLabel4) .addComponent(jLabel1) .addComponent(jTextField2) .addComponent(jComboBox1, 0, 83, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane1) .addGroup(layout.createSequentialGroup() .addComponent(jLabel5) .addGap(0, 0, Short.MAX_VALUE)))) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(103, 103, 103) .addComponent(jButton1)) .addGroup(layout.createSequentialGroup() .addGap(63, 63, 63) .addComponent(jLabel2))) .addGap(0, 0, Short.MAX_VALUE))) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup()

Page 28: User Documentation

.addContainerGap() .addComponent(jLabel2) .addGap(5, 5, 5) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel5) .addComponent(jLabel1)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel4) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 0, Short.MAX_VALUE)) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 114, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton1)) );

pack(); }// </editor-fold>

private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: }

private void jTextField2ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: }

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: int genId = jComboBox1.getSelectedIndex() + 1; String name = jTextField2.getText(); String desc = jTextArea1.getText(); System.out.println(genId + name + desc);

if (name == null || name.equals("")) { JOptionPane.showMessageDialog(null, "Please enter in a movie name."); } else if (desc == null || desc.equals("")) { JOptionPane.showMessageDialog(null, "Please enter in a movie description."); } else { Movies mov = new Movies(); mov.setMovieName(name); mov.setDesc(desc); mov.setGenreId(genId); try {

Page 29: User Documentation

if (myService.addMovie(mov)) { JOptionPane.showMessageDialog(null, "Movie Successfully added."); this.dispose(); } else { JOptionPane.showMessageDialog(null, "Movie Unsuccessfully added."); } } catch (RemoteException ex) { Logger.getLogger(AddMovie.class.getName()).log(Level.SEVERE, null, ex); } } //create the method used to add a new movie and check if all the values have been entered }

/** * @param args the command line arguments */ public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(AddMovie.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(AddMovie.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(AddMovie.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(AddMovie.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold>

/* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() {

Page 30: User Documentation

public void run() { new AddMovie().setVisible(true); } }); } // Variables declaration - do not modify private javax.swing.JButton jButton1; private javax.swing.JComboBox jComboBox1; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel5; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JTextArea jTextArea1; private javax.swing.JTextField jTextField2; // End of variables declaration }AdminGUI:/* * 2014/08/15 * Zach Stratenwerth * Video Store Project * Create the GUI for the Admin frame. */package adminGUI;

import java.awt.Frame;import java.rmi.RemoteException;import java.rmi.registry.LocateRegistry;import java.rmi.registry.Registry;import java.util.ArrayList;import java.util.logging.Level;import java.util.logging.Logger;import javax.swing.JOptionPane;import javax.swing.JTable;import myServer.ServerBeans.Movies;import myServer.service.ServiceInt;

public class AdminGUI extends javax.swing.JFrame {

public ServiceInt myService = null;

private void doConnection() { try { Registry myRegistry = LocateRegistry.getRegistry("localhost", 1099); myService = (ServiceInt) myRegistry.lookup("VideoStore"); } catch (Exception e) { e.printStackTrace(); } } //run a new connection on the new GUI.

Page 31: User Documentation

/** * Creates new form UserGUI */ public AdminGUI() { initComponents(); this.setLocationRelativeTo(null); doConnection(); try { setMoviesTable(); } catch (RemoteException ex) { Logger.getLogger(AdminGUI.class.getName()).log(Level.SEVERE, null, ex); } }

void setMoviesTable() throws RemoteException { String cols[] = {"ID", "Name", "Description", "Genre ID", "Genre Name"};

ArrayList<Movies> movies = myService.getAllMovies();

Object obj[][] = new Object[movies.size()][5]; int iterateMovie = 0; for (Movies movie : movies) { obj[iterateMovie][0] = movie.getMovieId(); obj[iterateMovie][1] = movie.getMovieName(); obj[iterateMovie][2] = movie.getDesc(); obj[iterateMovie][3] = movie.getGenreId(); obj[iterateMovie][4] = movie.getGenre().getGenreName(); iterateMovie++; }

jTable2 = new JTable(obj, cols); jScrollPane1.getViewport().add(jTable2); this.setVisible(true); } //set the movie table with the needed headers and values.

/** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() {

buttonGroup1 = new javax.swing.ButtonGroup(); jPanel1 = new javax.swing.JPanel(); MoviesTb = new javax.swing.JTabbedPane(); HomeTb = new javax.swing.JPanel(); AdminLb = new javax.swing.JLabel();

Page 32: User Documentation

jPanel3 = new javax.swing.JPanel(); jPanel4 = new javax.swing.JPanel(); SearchLb = new javax.swing.JLabel(); SearchTx = new javax.swing.JTextField(); NameRb = new javax.swing.JRadioButton(); GenreRb = new javax.swing.JRadioButton(); AddBt = new javax.swing.JButton(); RemoveBt = new javax.swing.JButton(); SearchBt = new javax.swing.JButton(); jButton1 = new javax.swing.JButton(); jButton2 = new javax.swing.JButton(); jScrollPane1 = new javax.swing.JScrollPane(); jTable2 = new javax.swing.JTable(); jMenuBar1 = new javax.swing.JMenuBar(); FileBt = new javax.swing.JMenu(); LogoutBt = new javax.swing.JMenuItem(); ExitBt = new javax.swing.JMenuItem(); HelpBt = new javax.swing.JMenu(); AboutBt = new javax.swing.JMenuItem();

setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

AdminLb.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N AdminLb.setText("Welcome to the admin interface");

javax.swing.GroupLayout HomeTbLayout = new javax.swing.GroupLayout(HomeTb); HomeTb.setLayout(HomeTbLayout); HomeTbLayout.setHorizontalGroup( HomeTbLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(HomeTbLayout.createSequentialGroup() .addGap(199, 199, 199) .addComponent(AdminLb) .addContainerGap(219, Short.MAX_VALUE)) ); HomeTbLayout.setVerticalGroup( HomeTbLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(HomeTbLayout.createSequentialGroup() .addGap(167, 167, 167) .addComponent(AdminLb) .addContainerGap(246, Short.MAX_VALUE)) );

MoviesTb.addTab("Home", HomeTb);

SearchLb.setText("Search:");

buttonGroup1.add(NameRb); NameRb.setText("Name");

buttonGroup1.add(GenreRb); GenreRb.setText("Genre");

Page 33: User Documentation

GenreRb.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { GenreRbActionPerformed(evt); } });

AddBt.setText("Add Movie"); AddBt.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { AddBtActionPerformed(evt); } });

RemoveBt.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N RemoveBt.setText("Remove Movie"); RemoveBt.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { RemoveBtActionPerformed(evt); } });

SearchBt.setText("Search"); SearchBt.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { SearchBtActionPerformed(evt); } });

jButton1.setText("Add Genre"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } });

jButton2.setText("Refresh"); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); } });

javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4); jPanel4.setLayout(jPanel4Layout); jPanel4Layout.setHorizontalGroup( jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(SearchTx) .addGroup(jPanel4Layout.createSequentialGroup() .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(SearchBt)

Page 34: User Documentation

.addComponent(SearchLb) .addGroup(jPanel4Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(GenreRb) .addComponent(NameRb))) .addComponent(RemoveBt, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(AddBt, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap()) ); jPanel4Layout.setVerticalGroup( jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel4Layout.createSequentialGroup() .addGap(37, 37, 37) .addComponent(SearchLb) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(SearchTx, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(SearchBt) .addGap(18, 18, 18) .addComponent(NameRb) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(GenreRb) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(AddBt) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(RemoveBt) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton2) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) );

jTable2.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { {null, null, null, null}, {null, null, null, null}, {null, null, null, null}, {null, null, null, null} }, new String [] { "Title 1", "Title 2", "Title 3", "Title 4"

Page 35: User Documentation

} )); jScrollPane1.setViewportView(jTable2);

javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); jPanel3.setLayout(jPanel3Layout); jPanel3Layout.setHorizontalGroup( jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup() .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, 105, Short.MAX_VALUE) .addGap(18, 18, 18) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 585, javax.swing.GroupLayout.PREFERRED_SIZE)) ); jPanel3Layout.setVerticalGroup( jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup() .addGap(25, 25, 25) .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(40, 40, 40)) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 435, Short.MAX_VALUE) );

MoviesTb.addTab("Movies", jPanel3);

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(MoviesTb) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(MoviesTb) );

FileBt.setText("File");

LogoutBt.setText("Logout"); LogoutBt.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { LogoutBtActionPerformed(evt); } }); FileBt.add(LogoutBt);

ExitBt.setText("Exit"); ExitBt.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) {

Page 36: User Documentation

ExitBtActionPerformed(evt); } }); FileBt.add(ExitBt);

jMenuBar1.add(FileBt);

HelpBt.setText("Help");

AboutBt.setText("About"); AboutBt.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { AboutBtActionPerformed(evt); } }); HelpBt.add(AboutBt);

jMenuBar1.add(HelpBt);

setJMenuBar(jMenuBar1);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) );

pack(); }// </editor-fold>

private void RemoveBtActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: int id; String name = null; int row = 0; if (jTable2.getSelectedColumn() > 0) { row = jTable2.getSelectedRow(); id = (Integer) jTable2.getValueAt(row, 0); name = (String) jTable2.getValueAt(row, 1); try { if (myService.deleteMovie(id)) { JOptionPane.showMessageDialog(null, "deleted: " + name, "Success", JOptionPane.INFORMATION_MESSAGE); } else {

Page 37: User Documentation

JOptionPane.showMessageDialog(null, "error deleting: " + name, "Error", JOptionPane.ERROR_MESSAGE); } } catch (RemoteException ex) { Logger.getLogger(AdminGUI.class.getName()).log(Level.SEVERE, null, ex); } } else { JOptionPane.showMessageDialog(null, "please select a movie to delete", "Error", JOptionPane.ERROR_MESSAGE); } //Create all functions for the remove movie button }

private void GenreRbActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: }

private void AboutBtActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: JOptionPane.showMessageDialog(null, "1.Adding a movie - Ensure the movie name begins with an uppercase letter, " + "have a valid genre and should not exist in the database. The movie name, " + "description, genre ID and image filepath need to be entered.\n" + "2.Removing a movie - In this case, only the movie ID needs to be entered.\n", "Help Menu", JOptionPane.PLAIN_MESSAGE); //Create the help menu details }

private void ExitBtActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here:

String[] exit = {"Exit", "Minimize", "Cancel"}; int response = JOptionPane.showOptionDialog(null, "Are you sure you want to exit?", "Exit!", 0, JOptionPane.QUESTION_MESSAGE, null, exit, exit[2]); if (response == 0) { System.exit(0); } else if (response == 1) { this.setState(Frame.ICONIFIED); } else { } //Create the functions for the exit button and confirm messages. }

private void AddBtActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here:

Page 38: User Documentation

new AddMovie().setVisible(true); }

private void SearchBtActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: String lookup = SearchTx.getText(); if (lookup.equals(null) || lookup == "") { JOptionPane.showMessageDialog(null, "You have not searched anything"); } else { if (NameRb.isSelected()) { String cols[] = {"ID", "Name", "Description", "Genre ID", "Genre Name"};

ArrayList<Movies> movies = null; try { movies = myService.getMovieByName(lookup); } catch (RemoteException ex) { Logger.getLogger(AdminGUI.class.getName()).log(Level.SEVERE, null, ex); } Object obj[][] = new Object[movies.size()][5];

int iterateMovie = 0; for (Movies movie : movies) { obj[iterateMovie][0] = movie.getMovieId(); obj[iterateMovie][1] = movie.getMovieName(); obj[iterateMovie][2] = movie.getDesc(); obj[iterateMovie][3] = movie.getGenreId(); obj[iterateMovie][4] = movie.getGenre().getGenreName(); iterateMovie++; } jTable2 = new JTable(obj, cols); jScrollPane1.getViewport().add(jTable2); } else if (GenreRb.isSelected()) {

String cols[] = {"ID", "Name", "Description", "Genre ID", "Genre Name"};

ArrayList<Movies> movies = null; try { movies = myService.getMovieByGenre(lookup); } catch (RemoteException ex) { Logger.getLogger(AdminGUI.class.getName()).log(Level.SEVERE, null, ex); }

Object obj[][] = new Object[movies.size()][5];

int iterateMovie = 0; for (Movies movie : movies) { obj[iterateMovie][0] = movie.getMovieId(); obj[iterateMovie][1] = movie.getMovieName(); obj[iterateMovie][2] = movie.getDesc(); obj[iterateMovie][3] = movie.getGenreId(); obj[iterateMovie][4] = movie.getGenre().getGenreName();

Page 39: User Documentation

iterateMovie++; } jTable2 = new JTable(obj, cols); jScrollPane1.getViewport().add(jTable2);

} else { JOptionPane.showMessageDialog(null, "Please select name or genre"); } } //Create all the need methods and functions from the search textfield. }

private void LogoutBtActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: this.dispose(); }

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: new AddGenre().setVisible(true); }

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { try { // TODO add your handling code here: setMoviesTable(); } catch (RemoteException ex) { Logger.getLogger(AdminGUI.class.getName()).log(Level.SEVERE, null, ex); } //used to refresh the page. } /** * @param args the command line arguments */ public static void main(String args[]) { /* * Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* * If Nimbus (introduced in Java SE 6) is not available, stay with the * default look and feel. For details see * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; }

Page 40: User Documentation

} } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(AdminGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(AdminGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(AdminGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(AdminGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold>

/* * Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new AdminGUI().setVisible(true); } }); } // Variables declaration - do not modify private javax.swing.JMenuItem AboutBt; private javax.swing.JButton AddBt; private javax.swing.JLabel AdminLb; private javax.swing.JMenuItem ExitBt; private javax.swing.JMenu FileBt; private javax.swing.JRadioButton GenreRb; private javax.swing.JMenu HelpBt; private javax.swing.JPanel HomeTb; private javax.swing.JMenuItem LogoutBt; private javax.swing.JTabbedPane MoviesTb; private javax.swing.JRadioButton NameRb; private javax.swing.JButton RemoveBt; private javax.swing.JButton SearchBt; private javax.swing.JLabel SearchLb; private javax.swing.JTextField SearchTx; private javax.swing.ButtonGroup buttonGroup1; private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JMenuBar jMenuBar1; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel3;

Page 41: User Documentation

private javax.swing.JPanel jPanel4; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JTable jTable2; // End of variables declaration }LoginGUI:/* * 2014/08/15 * Zach Stratenwerth * Video Store Project * Create the GUI for the login frame. */package adminGUI;

import java.rmi.RemoteException;import java.rmi.registry.LocateRegistry;import java.rmi.registry.Registry;import java.util.logging.Level;import java.util.logging.Logger;import javax.swing.JOptionPane;import myServer.service.ServiceInt;

public class LoginGUI extends javax.swing.JFrame {

public ServiceInt myService = null;

private void doConnection() { try { Registry myRegistry = LocateRegistry.getRegistry("localhost", 1099);

myService = (ServiceInt) myRegistry.lookup("VideoStore"); } catch (Exception e) { e.printStackTrace(); } } //run a new connection on the new GUI. /** * Creates new form LoginGUI */ public LoginGUI() { initComponents(); this.setLocationRelativeTo(null); setVisible(true); doConnection(); }

/** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor.

Page 42: User Documentation

*/ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() {

UsernameTx = new javax.swing.JTextField(); PasswordTx = new javax.swing.JPasswordField(); UsernameLb = new javax.swing.JLabel(); PasswordLb = new javax.swing.JLabel(); jLabel1 = new javax.swing.JLabel(); LoginBt = new javax.swing.JButton();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

PasswordTx.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { PasswordTxActionPerformed(evt); } });

UsernameLb.setText("Username:");

PasswordLb.setText("Password:");

jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N jLabel1.setText("Administrator Login");

LoginBt.setText("Login"); LoginBt.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { LoginBtActionPerformed(evt); } });

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap(46, Short.MAX_VALUE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(LoginBt) .addComponent(PasswordTx, javax.swing.GroupLayout.PREFERRED_SIZE, 111, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(PasswordLb) .addComponent(UsernameLb) .addComponent(UsernameTx, javax.swing.GroupLayout.PREFERRED_SIZE, 111, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel1)) .addGap(41, 41, 41)) );

Page 43: User Documentation

layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jLabel1) .addGap(12, 12, 12) .addComponent(UsernameLb) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(UsernameTx, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(PasswordLb) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(PasswordTx, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(LoginBt)) );

pack(); }// </editor-fold>

private void PasswordTxActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: }

private void LoginBtActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here:\ String un = UsernameTx.getText(); String pass = PasswordTx.getText(); boolean passed = false; try { passed = myService.checkLogin(un, pass); } catch (RemoteException ex) { Logger.getLogger(LoginGUI.class.getName()).log(Level.SEVERE, null, ex); } if (passed) { new AdminGUI().setVisible(true); this.dispose(); } else { JOptionPane.showMessageDialog(null, "Please enter in your username and password carefully.", "Error", JOptionPane.ERROR_MESSAGE); } //Create method for the login button and provides a error messges. }

/** * @param args the command line arguments */ public static void main(String args[]) { /*

Page 44: User Documentation

* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* * If Nimbus (introduced in Java SE 6) is not available, stay with the * default look and feel. For details see * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(LoginGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(LoginGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(LoginGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(LoginGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold>

/* * Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new LoginGUI().setVisible(true); } //run the main method }); } // Variables declaration - do not modify private javax.swing.JButton LoginBt; private javax.swing.JLabel PasswordLb; private javax.swing.JPasswordField PasswordTx; private javax.swing.JLabel UsernameLb; private javax.swing.JTextField UsernameTx;

Page 45: User Documentation

private javax.swing.JLabel jLabel1; // End of variables declaration }MyServer package:MyVideoStore class:/* * 2014/08/15 * Zach Stratenwerth * Video Store Project * Used to run the main method within the video store app . */package myServer;

import adminGUI.AdminGUI;import myServer.LoadBar.LoadBar;

public class MyVideoStore {

/** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(LoadBar.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(LoadBar.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(LoadBar.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(LoadBar.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } new LoadBar(); //runs a new instance of the loadbar }

Page 46: User Documentation

}LoadBar class:/* * 2014/08/15 * Zach Stratenwerth * Video Store Project * Create the GUI for the loading bar. */package myServer.LoadBar;

import java.util.logging.Level;import java.util.logging.Logger;import userGUI.UserGUI;

public class LoadBar extends javax.swing.JFrame {

final void loader() { for (int i = 0; i < (jProgressBar1.getMaximum() + 1); i++) { jProgressBar1.setValue(i); try { Thread.sleep(15); } catch (InterruptedException ex) { Logger.getLogger(LoadBar.class.getName()).log(Level.SEVERE, null, ex); } } //create the loader bar and the speed it loads at.

int a = jProgressBar1.getMaximum(); int b = jProgressBar1.getValue(); if (a == b) { try { new UserGUI().setVisible(true); } catch (Exception ex) { Logger.getLogger(LoadBar.class.getName()).log(Level.SEVERE, null, ex); } this.dispose(); } } //disposes of the GUI after the ifs are true.

/** * Creates new form LoadBar */ public LoadBar() { this.setUndecorated(true); initComponents(); this.setLocationRelativeTo(null); setVisible(true); loader(); }

Page 47: User Documentation

/** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() {

jProgressBar1 = new javax.swing.JProgressBar(); jLabel1 = new javax.swing.JLabel();

setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

jProgressBar1.setForeground(new java.awt.Color(51, 102, 255)); jProgressBar1.setToolTipText("");

jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/myServer/LoadBar/20120328045117-video-icon.jpg"))); // NOI18N jLabel1.setText("VideoPic");

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jProgressBar1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 441, javax.swing.GroupLayout.PREFERRED_SIZE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jProgressBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)) );

jLabel1.getAccessibleContext().setAccessibleName("videoPic");

pack(); }// </editor-fold>

/** * @param args the command line arguments */ public static void main(String args[]) { /* * Set the Nimbus look and feel

Page 48: User Documentation

*/ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* * If Nimbus (introduced in Java SE 6) is not available, stay with the * default look and feel. For details see * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(LoadBar.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(LoadBar.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(LoadBar.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(LoadBar.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold>

/* * Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new LoadBar(); } }); } // Variables declaration - do not modify private javax.swing.JLabel jLabel1; private javax.swing.JProgressBar jProgressBar1; // End of variables declaration }ServerBean package:Genre class:/*

Page 49: User Documentation

* 2014/08/15 * Zach Stratenwerth * Video Store Project * Genre bean, used to get and set all genre variables. */package myServer.ServerBeans;

import java.io.Serializable;

public class Genre implements Serializable {

private int genreId; private String genreName;

public int getGenreId() { return genreId; }

public void setGenreId(int genreId) { this.genreId = genreId; }

public String getGenreName() { return genreName; }

public void setGenreName(String genreName) { this.genreName = genreName; }}//Create all required getters and settersMovie class:/* * 2014/08/15 * Zach Stratenwerth * Video Store Project * Genre bean, used to get and set all movie variables. */package myServer.ServerBeans;

import java.io.Serializable;

public class Movies implements Serializable{ private int movieId; private String movieName; private String desc; private int genreId; private Genre genre; public String getDesc() { return desc;

Page 50: User Documentation

}

public void setDesc(String desc) { this.desc = desc; }

public int getGenreId() { return genreId; }

public void setGenreId(int genreId) { this.genreId = genreId; }

public int getMovieId() { return movieId; }

public void setMovieId(int movieId) { this.movieId = movieId; }

public String getMovieName() { return movieName; }

public void setMovieName(String movieName) { this.movieName = movieName; }

public Genre getGenre() { return genre; }

public void setGenre(Genre genre) { this.genre = genre; }}//Create all required getters and settersUsers class:/* * 2014/08/15 * Zach Stratenwerth * Video Store Project * Genre bean, used to get and set all user variables. */package myServer.ServerBeans;

import java.io.Serializable;

public class Users implements Serializable{

Page 51: User Documentation

private int userId; private String userName; private String password;

public String getPassword() { return password; }

public void setPassword(String password) { this.password = password; }

public int getUserId() { return userId; }

public void setUserId(int userId) { this.userId = userId; }

public String getUserName() { return userName; }

public void setUserName(String userName) { this.userName = userName; }}//Create all required getters and settersService package:ServiceInt class:/* * 2014/08/15 * Zach Stratenwerth * Video Store Project * Used to call all the impelmentation through this interface. */package myServer.service;

import java.rmi.Remote;import java.rmi.RemoteException;import java.util.ArrayList;import myServer.ServerBeans.Genre;import myServer.ServerBeans.Movies;

public interface ServiceInt extends Remote {

public boolean checkLogin(String userName, String password) throws RemoteException;

public ArrayList<Movies> getAllMovies() throws RemoteException;

Page 52: User Documentation

public ArrayList<Movies> getMovieByName(String movieName) throws RemoteException;

public ArrayList<Movies> getMovieByGenre(String genreName) throws RemoteException;

public boolean addMovie(Movies movie) throws RemoteException;

public boolean deleteMovie(int movieID) throws RemoteException;

public ArrayList<Genre> getAllGenres() throws RemoteException;

public boolean addGenre(Genre genre) throws RemoteException;}//Creatation of all the required implementation interfacesUserGUI package:UserGUI class:/* * 2014/08/15 * Zach Stratenwerth * Video Store Project * Used to create the GUI for the user frame. */package userGUI;

import adminGUI.LoginGUI;import java.awt.Frame;import java.rmi.RemoteException;import java.rmi.registry.LocateRegistry;import java.rmi.registry.Registry;import java.util.ArrayList;import java.util.Vector;import java.util.logging.Level;import java.util.logging.Logger;import javax.swing.JOptionPane;import javax.swing.JTable;import myServer.ServerBeans.Movies;import myServer.service.ServiceInt;

public class UserGUI extends javax.swing.JFrame {

public ServiceInt myService = null;

private void doConnection() { try { Registry myRegistry = LocateRegistry.getRegistry("localhost", 1099); myService = (ServiceInt) myRegistry.lookup("VideoStore"); } catch (Exception e) { e.printStackTrace(); } } //Creates a new connection for the new instance of the GUI.

Page 53: User Documentation

/** * Creates new form UserGUI */ public UserGUI() throws Exception { initComponents(); this.setLocationRelativeTo(null);

doConnection(); try { setMoviesTable(); } catch (RemoteException ex) { Logger.getLogger(UserGUI.class.getName()).log(Level.SEVERE, null, ex); } }

void setMoviesTable() throws RemoteException { String cols[] = {"ID", "Name", "Description", "Genre ID", "Genre Name"};

ArrayList<Movies> movies = myService.getAllMovies();

Object obj[][] = new Object[movies.size()][5];

int iterateMovie = 0; for (Movies movie : movies) { obj[iterateMovie][0] = movie.getMovieId(); obj[iterateMovie][1] = movie.getMovieName(); obj[iterateMovie][2] = movie.getDesc(); obj[iterateMovie][3] = movie.getGenreId(); obj[iterateMovie][4] = movie.getGenre().getGenreName(); iterateMovie++; } jTable2 = new JTable(obj, cols); jScrollPane1.getViewport().add(jTable2); this.setVisible(true); } //sets the table with the new headers and values.

/** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() {

buttonGroup1 = new javax.swing.ButtonGroup(); jPanel1 = new javax.swing.JPanel(); jTabbedPane1 = new javax.swing.JTabbedPane(); jPanel2 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel();

Page 54: User Documentation

jPanel3 = new javax.swing.JPanel(); jPanel4 = new javax.swing.JPanel(); SearchLb = new javax.swing.JLabel(); SearchTx = new javax.swing.JTextField(); NameRb = new javax.swing.JRadioButton(); GenreRb = new javax.swing.JRadioButton(); SearchBt = new javax.swing.JButton(); jScrollPane1 = new javax.swing.JScrollPane(); jTable2 = new javax.swing.JTable(); jMenuBar1 = new javax.swing.JMenuBar(); FileBt = new javax.swing.JMenu(); AdminLogBt = new javax.swing.JMenuItem(); ExitBt = new javax.swing.JMenuItem(); HelpBt = new javax.swing.JMenu(); AboutBt = new javax.swing.JMenuItem();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

jLabel1.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N jLabel1.setText("Welcome to Zach's Video Store");

javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addGap(200, 200, 200) .addComponent(jLabel1) .addContainerGap(234, Short.MAX_VALUE)) ); jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addGap(180, 180, 180) .addComponent(jLabel1) .addContainerGap(227, Short.MAX_VALUE)) );

jTabbedPane1.addTab("Home", jPanel2);

SearchLb.setText("Search:");

buttonGroup1.add(NameRb); NameRb.setText("Name"); NameRb.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { NameRbActionPerformed(evt); } });

buttonGroup1.add(GenreRb);

Page 55: User Documentation

GenreRb.setText("Genre"); GenreRb.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { GenreRbActionPerformed(evt); } });

SearchBt.setText("Search"); SearchBt.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { SearchBtActionPerformed(evt); } });

javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4); jPanel4.setLayout(jPanel4Layout); jPanel4Layout.setHorizontalGroup( jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(SearchTx) .addGroup(jPanel4Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(NameRb) .addComponent(GenreRb)) .addContainerGap(24, Short.MAX_VALUE)) .addGroup(jPanel4Layout.createSequentialGroup() .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(SearchLb) .addComponent(SearchBt)) .addGap(0, 0, Short.MAX_VALUE)) ); jPanel4Layout.setVerticalGroup( jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel4Layout.createSequentialGroup() .addGap(37, 37, 37) .addComponent(SearchLb) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(SearchTx, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(SearchBt) .addGap(17, 17, 17) .addComponent(NameRb) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(GenreRb) .addContainerGap(232, Short.MAX_VALUE)) );

jTable2.setModel(new javax.swing.table.DefaultTableModel(

Page 56: User Documentation

new Object [][] { {null, null, null, null}, {null, null, null, null}, {null, null, null, null}, {null, null, null, null} }, new String [] { "Title 1", "Title 2", "Title 3", "Title 4" } )); jScrollPane1.setViewportView(jTable2);

javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); jPanel3.setLayout(jPanel3Layout); jPanel3Layout.setHorizontalGroup( jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup() .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 621, Short.MAX_VALUE)) ); jPanel3Layout.setVerticalGroup( jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup() .addGap(25, 25, 25) .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) );

jTabbedPane1.addTab("Movies", jPanel3);

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jTabbedPane1) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jTabbedPane1) );

FileBt.setText("File");

AdminLogBt.setText("Administrator login"); AdminLogBt.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) {

Page 57: User Documentation

AdminLogBtActionPerformed(evt); } }); FileBt.add(AdminLogBt);

ExitBt.setText("Exit"); ExitBt.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { ExitBtActionPerformed(evt); } }); FileBt.add(ExitBt);

jMenuBar1.add(FileBt);

HelpBt.setText("Help");

AboutBt.setText("About"); AboutBt.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { AboutBtActionPerformed(evt); } }); HelpBt.add(AboutBt);

jMenuBar1.add(HelpBt);

setJMenuBar(jMenuBar1);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) );

pack(); }// </editor-fold>

private void GenreRbActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: }

private void NameRbActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here:

Page 58: User Documentation

}

private void SearchBtActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: String lookup = SearchTx.getText(); if (lookup.equals(null) || lookup == "") { JOptionPane.showMessageDialog(null, "You have not searched anything"); } else { if (NameRb.isSelected()) { String cols[] = {"ID", "Name", "Description", "Genre ID", "Genre Name"};

ArrayList<Movies> movies = null; try { movies = myService.getMovieByName(lookup); } catch (RemoteException ex) { Logger.getLogger(UserGUI.class.getName()).log(Level.SEVERE, null, ex); }

Object obj[][] = new Object[movies.size()][5];

int iterateMovie = 0; for (Movies movie : movies) { obj[iterateMovie][0] = movie.getMovieId(); obj[iterateMovie][1] = movie.getMovieName(); obj[iterateMovie][2] = movie.getDesc(); obj[iterateMovie][3] = movie.getGenreId(); obj[iterateMovie][4] = movie.getGenre().getGenreName(); iterateMovie++; } jTable2 = new JTable(obj, cols); jScrollPane1.getViewport().add(jTable2); } else if (GenreRb.isSelected()) {

String cols[] = {"ID", "Name", "Description", "Genre ID", "Genre Name"};

ArrayList<Movies> movies = null; try { movies = myService.getMovieByGenre(lookup); } catch (RemoteException ex) { Logger.getLogger(UserGUI.class.getName()).log(Level.SEVERE, null, ex); }

Object obj[][] = new Object[movies.size()][5];

int iterateMovie = 0; for (Movies movie : movies) { obj[iterateMovie][0] = movie.getMovieId(); obj[iterateMovie][1] = movie.getMovieName(); obj[iterateMovie][2] = movie.getDesc(); obj[iterateMovie][3] = movie.getGenreId(); obj[iterateMovie][4] = movie.getGenre().getGenreName();

Page 59: User Documentation

iterateMovie++; } jTable2 = new JTable(obj, cols); jScrollPane1.getViewport().add(jTable2);

} else { JOptionPane.showMessageDialog(null, "Please select name or genre"); } } //create all the methods and function of the search textfield. }

private void ExitBtActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: String[] exit = {"Exit", "Minimize", "Cancel"}; int response = JOptionPane.showOptionDialog(null, "Are you sure you want to exit?", "Exit!", 0, JOptionPane.QUESTION_MESSAGE, null, exit, exit[2]); if (response == 0) { System.exit(0); } else if (response == 1) { this.setState(Frame.ICONIFIED); } else { } //creates te functions behind the exit button. }

private void AdminLogBtActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: new LoginGUI(); }

private void AboutBtActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: JOptionPane.showMessageDialog(null, "1. If your movie search returns more than one result, please be more specific to " + "view description.\n" + "2. You must be connected to the server to use any client functions. \n" + "3. A user may enter the admin interface, provided they have a valid username and password. \n" + "4. If you are unsure of what to search, clear the search area and click on search while having the movie name selected.\n", "Help Menu", JOptionPane.PLAIN_MESSAGE); //Defines the help menu details. }

/**

Page 60: User Documentation

* @param args the command line arguments */ public static void main(String args[]) { /* * Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* * If Nimbus (introduced in Java SE 6) is not available, stay with the * default look and feel. For details see * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(UserGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(UserGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(UserGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(UserGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold>

/* * Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { try { new UserGUI(); } catch (Exception ex) { Logger.getLogger(UserGUI.class.getName()).log(Level.SEVERE, null, ex); } } });

Page 61: User Documentation

} // Variables declaration - do not modify private javax.swing.JMenuItem AboutBt; private javax.swing.JMenuItem AdminLogBt; private javax.swing.JMenuItem ExitBt; private javax.swing.JMenu FileBt; private javax.swing.JRadioButton GenreRb; private javax.swing.JMenu HelpBt; private javax.swing.JRadioButton NameRb; private javax.swing.JButton SearchBt; private javax.swing.JLabel SearchLb; private javax.swing.JTextField SearchTx; private javax.swing.ButtonGroup buttonGroup1; private javax.swing.JLabel jLabel1; private javax.swing.JMenuBar jMenuBar1; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; private javax.swing.JPanel jPanel3; private javax.swing.JPanel jPanel4; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JTabbedPane jTabbedPane1; private javax.swing.JTable jTable2; // End of variables declaration }