@@ -1,7 +1,7 @@ | |||||
package libsys; | package libsys; | ||||
/* | /* | ||||
* Written by : Bin Hong Lee | * Written by : Bin Hong Lee | ||||
* Last edited : 5/28/2017 | |||||
* Last edited : 5/30/2017 | |||||
*/ | */ | ||||
class Book | class Book | ||||
@@ -23,12 +23,11 @@ class Book | |||||
this.status = "NOT AVAILABLE"; | this.status = "NOT AVAILABLE"; | ||||
} | } | ||||
//Constructor with book title | |||||
public Book(String title, int id) | |||||
public Book(String title, int id, String status) | |||||
{ | { | ||||
this.title = title; | this.title = title; | ||||
this.id = id; | this.id = id; | ||||
this.status = "AVAILABLE"; | |||||
this.status = status; | |||||
} | } | ||||
public Book(int id, String title, String status, int[] dueDate) | public Book(int id, String title, String status, int[] dueDate) | ||||
@@ -58,7 +58,7 @@ class BookFactory | |||||
} | } | ||||
this.bookFilename = bookFilename; | this.bookFilename = bookFilename; | ||||
id = getBook(books.size()-1).getId() + 1; | |||||
id = books.get(books.size() - 1).getId() + 1; | |||||
} | } | ||||
public void toJsonFile() | public void toJsonFile() | ||||
@@ -91,9 +91,9 @@ class BookFactory | |||||
this.bookFilename = bookFilename; | this.bookFilename = bookFilename; | ||||
} | } | ||||
public Book newBook(String title) | |||||
public Book newBook(String title, String status) | |||||
{ | { | ||||
Book temp = new Book(title, id); | |||||
Book temp = new Book(title, id, status); | |||||
books.add(temp); | books.add(temp); | ||||
id++; | id++; | ||||
@@ -104,14 +104,35 @@ class BookFactory | |||||
public Book getBook(int index) | public Book getBook(int index) | ||||
{ | { | ||||
try | |||||
return search(index, 0, books.size() - 1); | |||||
} | |||||
public Book search(int index, int start, int end) | |||||
{ | |||||
if (start == end && books.get(start).getId() == index) | |||||
{ | { | ||||
return books.get(index); | |||||
return books.get(start); | |||||
} | } | ||||
catch (Exception e) | |||||
if (start >= end) | |||||
{ | { | ||||
throw new NullPointerException(); | throw new NullPointerException(); | ||||
} | } | ||||
int currentId = ((start + end) / 2); | |||||
if (books.get(currentId).getId() == index) | |||||
{ | |||||
return books.get(currentId); | |||||
} | |||||
else if (books.get(currentId).getId() > index) | |||||
{ | |||||
return search(index, start, currentId - 1); | |||||
} | |||||
else | |||||
{ | |||||
return search(index, currentId + 1, end); | |||||
} | |||||
} | } | ||||
public Book getBook(String title) | public Book getBook(String title) | ||||
@@ -331,6 +331,9 @@ | |||||
<Properties> | <Properties> | ||||
<Property name="text" type="java.lang.String" value="Add new book"/> | <Property name="text" type="java.lang.String" value="Add new book"/> | ||||
</Properties> | </Properties> | ||||
<Events> | |||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="createBookBtnActionPerformed"/> | |||||
</Events> | |||||
</Component> | </Component> | ||||
<Component class="javax.swing.JButton" name="createUserBtn"> | <Component class="javax.swing.JButton" name="createUserBtn"> | ||||
<Properties> | <Properties> | ||||
@@ -196,6 +196,11 @@ public class MainGUI extends javax.swing.JFrame | |||||
nameLabel.setText("Welcome to abc Library"); | nameLabel.setText("Welcome to abc Library"); | ||||
createBookBtn.setText("Add new book"); | createBookBtn.setText("Add new book"); | ||||
createBookBtn.addActionListener(new java.awt.event.ActionListener() { | |||||
public void actionPerformed(java.awt.event.ActionEvent evt) { | |||||
createBookBtnActionPerformed(evt); | |||||
} | |||||
}); | |||||
createUserBtn.setText("Add new user"); | createUserBtn.setText("Add new user"); | ||||
createUserBtn.addActionListener(new java.awt.event.ActionListener() { | createUserBtn.addActionListener(new java.awt.event.ActionListener() { | ||||
@@ -282,6 +287,17 @@ public class MainGUI extends javax.swing.JFrame | |||||
} | } | ||||
}//GEN-LAST:event_createUserBtnActionPerformed | }//GEN-LAST:event_createUserBtnActionPerformed | ||||
private void createBookBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_createBookBtnActionPerformed | |||||
NewBookDialog newBookUI = new NewBookDialog(this, true); | |||||
newBookUI.setVisible(true); | |||||
if (newBookUI.getReturnStatus() != -1) | |||||
{ | |||||
bookSearch.setText(String.valueOf(handler.books.newBook(newBookUI.getName(), newBookUI.getStatus()).getId())); | |||||
bookSearchBtnActionPerformed(evt); | |||||
} | |||||
}//GEN-LAST:event_createBookBtnActionPerformed | |||||
private void rentBtnActionPerformed(java.awt.event.ActionEvent evt) | private void rentBtnActionPerformed(java.awt.event.ActionEvent evt) | ||||
{ | { | ||||
User thisUser = handler.users.getUser(Integer.parseInt(userSearch.getText())); | User thisUser = handler.users.getUser(Integer.parseInt(userSearch.getText())); | ||||
@@ -0,0 +1,128 @@ | |||||
<?xml version="1.0" encoding="UTF-8" ?> | |||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> | |||||
<Properties> | |||||
<Property name="defaultCloseOperation" type="int" value="2"/> | |||||
</Properties> | |||||
<SyntheticProperties> | |||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/> | |||||
<SyntheticProperty name="generateCenter" type="boolean" value="false"/> | |||||
</SyntheticProperties> | |||||
<AuxValues> | |||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> | |||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> | |||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> | |||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> | |||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> | |||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> | |||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> | |||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> | |||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> | |||||
</AuxValues> | |||||
<Layout> | |||||
<DimensionLayout dim="0"> | |||||
<Group type="103" groupAlignment="0" attributes="0"> | |||||
<Group type="102" attributes="0"> | |||||
<EmptySpace max="-2" attributes="0"/> | |||||
<Group type="103" groupAlignment="0" attributes="0"> | |||||
<Group type="102" alignment="0" attributes="0"> | |||||
<Component id="createBtn" min="-2" max="-2" attributes="0"/> | |||||
<EmptySpace pref="23" max="32767" attributes="0"/> | |||||
<Component id="cancelBtn" min="-2" max="-2" attributes="0"/> | |||||
</Group> | |||||
<Group type="102" attributes="0"> | |||||
<Component id="title" min="-2" max="-2" attributes="0"/> | |||||
<EmptySpace min="0" pref="100" max="32767" attributes="0"/> | |||||
</Group> | |||||
<Group type="102" alignment="0" attributes="0"> | |||||
<Group type="103" groupAlignment="0" attributes="0"> | |||||
<Component id="statusLbl" alignment="0" min="-2" max="-2" attributes="0"/> | |||||
<Component id="titleLbl" alignment="0" min="-2" max="-2" attributes="0"/> | |||||
</Group> | |||||
<EmptySpace type="unrelated" max="-2" attributes="0"/> | |||||
<Group type="103" groupAlignment="0" attributes="0"> | |||||
<Component id="titleTxtField" max="32767" attributes="0"/> | |||||
<Component id="statusComboBox" max="32767" attributes="0"/> | |||||
</Group> | |||||
</Group> | |||||
</Group> | |||||
<EmptySpace max="-2" attributes="0"/> | |||||
</Group> | |||||
</Group> | |||||
</DimensionLayout> | |||||
<DimensionLayout dim="1"> | |||||
<Group type="103" groupAlignment="0" attributes="0"> | |||||
<Group type="102" alignment="0" attributes="0"> | |||||
<EmptySpace max="-2" attributes="0"/> | |||||
<Component id="title" min="-2" max="-2" attributes="0"/> | |||||
<EmptySpace type="unrelated" max="-2" attributes="0"/> | |||||
<Group type="103" groupAlignment="3" attributes="0"> | |||||
<Component id="titleLbl" alignment="3" min="-2" max="-2" attributes="0"/> | |||||
<Component id="titleTxtField" alignment="3" min="-2" max="-2" attributes="0"/> | |||||
</Group> | |||||
<EmptySpace type="separate" max="-2" attributes="0"/> | |||||
<Group type="103" groupAlignment="3" attributes="0"> | |||||
<Component id="statusLbl" alignment="3" min="-2" max="-2" attributes="0"/> | |||||
<Component id="statusComboBox" alignment="3" min="-2" max="-2" attributes="0"/> | |||||
</Group> | |||||
<EmptySpace max="32767" attributes="0"/> | |||||
<Group type="103" groupAlignment="3" attributes="0"> | |||||
<Component id="createBtn" alignment="3" min="-2" max="-2" attributes="0"/> | |||||
<Component id="cancelBtn" alignment="3" min="-2" max="-2" attributes="0"/> | |||||
</Group> | |||||
<EmptySpace max="-2" attributes="0"/> | |||||
</Group> | |||||
</Group> | |||||
</DimensionLayout> | |||||
</Layout> | |||||
<SubComponents> | |||||
<Component class="javax.swing.JLabel" name="title"> | |||||
<Properties> | |||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> | |||||
<Font name="Lucida Grande" size="18" style="0"/> | |||||
</Property> | |||||
<Property name="text" type="java.lang.String" value="New Book"/> | |||||
</Properties> | |||||
</Component> | |||||
<Component class="javax.swing.JLabel" name="titleLbl"> | |||||
<Properties> | |||||
<Property name="text" type="java.lang.String" value="Title :"/> | |||||
</Properties> | |||||
</Component> | |||||
<Component class="javax.swing.JLabel" name="statusLbl"> | |||||
<Properties> | |||||
<Property name="text" type="java.lang.String" value="Status :"/> | |||||
</Properties> | |||||
</Component> | |||||
<Component class="javax.swing.JButton" name="createBtn"> | |||||
<Properties> | |||||
<Property name="text" type="java.lang.String" value="Add book"/> | |||||
</Properties> | |||||
<Events> | |||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="createBtnActionPerformed"/> | |||||
</Events> | |||||
</Component> | |||||
<Component class="javax.swing.JButton" name="cancelBtn"> | |||||
<Properties> | |||||
<Property name="text" type="java.lang.String" value="Cancel"/> | |||||
</Properties> | |||||
<Events> | |||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cancelBtnActionPerformed"/> | |||||
</Events> | |||||
</Component> | |||||
<Component class="javax.swing.JTextField" name="titleTxtField"> | |||||
</Component> | |||||
<Component class="javax.swing.JComboBox" name="statusComboBox"> | |||||
<Properties> | |||||
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor"> | |||||
<Connection code="new javax.swing.DefaultComboBoxModel(statusOptions)" type="code"/> | |||||
</Property> | |||||
</Properties> | |||||
<AuxValues> | |||||
<AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new javax.swing.JComboBox()"/> | |||||
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> | |||||
</AuxValues> | |||||
</Component> | |||||
</SubComponents> | |||||
</Form> |
@@ -0,0 +1,195 @@ | |||||
package libsys; | |||||
public class NewBookDialog extends javax.swing.JDialog { | |||||
/** | |||||
* Creates new form NewBookDialog | |||||
* @param parent | |||||
* @param modal | |||||
*/ | |||||
public NewBookDialog(java.awt.Frame parent, boolean modal) { | |||||
super(parent, modal); | |||||
initComponents(); | |||||
} | |||||
/** | |||||
* @return the return status of this dialog - one of RET_OK or RET_CANCEL | |||||
*/ | |||||
public int getReturnStatus() { | |||||
return returnStatus; | |||||
} | |||||
@Override | |||||
public String getName() { | |||||
return name; | |||||
} | |||||
public String getStatus() | |||||
{ | |||||
return status; | |||||
} | |||||
/** | |||||
* 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">//GEN-BEGIN:initComponents | |||||
private void initComponents() { | |||||
title = new javax.swing.JLabel(); | |||||
titleLbl = new javax.swing.JLabel(); | |||||
statusLbl = new javax.swing.JLabel(); | |||||
createBtn = new javax.swing.JButton(); | |||||
cancelBtn = new javax.swing.JButton(); | |||||
titleTxtField = new javax.swing.JTextField(); | |||||
statusComboBox = new javax.swing.JComboBox(); | |||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); | |||||
title.setFont(new java.awt.Font("Lucida Grande", 0, 18)); // NOI18N | |||||
title.setText("New Book"); | |||||
titleLbl.setText("Title :"); | |||||
statusLbl.setText("Status :"); | |||||
createBtn.setText("Add book"); | |||||
createBtn.addActionListener(new java.awt.event.ActionListener() { | |||||
public void actionPerformed(java.awt.event.ActionEvent evt) { | |||||
createBtnActionPerformed(evt); | |||||
} | |||||
}); | |||||
cancelBtn.setText("Cancel"); | |||||
cancelBtn.addActionListener(new java.awt.event.ActionListener() { | |||||
public void actionPerformed(java.awt.event.ActionEvent evt) { | |||||
cancelBtnActionPerformed(evt); | |||||
} | |||||
}); | |||||
statusComboBox.setModel(new javax.swing.DefaultComboBoxModel(statusOptions)); | |||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); | |||||
getContentPane().setLayout(layout); | |||||
layout.setHorizontalGroup( | |||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |||||
.addGroup(layout.createSequentialGroup() | |||||
.addContainerGap() | |||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |||||
.addGroup(layout.createSequentialGroup() | |||||
.addComponent(createBtn) | |||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 23, Short.MAX_VALUE) | |||||
.addComponent(cancelBtn)) | |||||
.addGroup(layout.createSequentialGroup() | |||||
.addComponent(title) | |||||
.addGap(0, 100, Short.MAX_VALUE)) | |||||
.addGroup(layout.createSequentialGroup() | |||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |||||
.addComponent(statusLbl) | |||||
.addComponent(titleLbl)) | |||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) | |||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |||||
.addComponent(titleTxtField) | |||||
.addComponent(statusComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))) | |||||
.addContainerGap()) | |||||
); | |||||
layout.setVerticalGroup( | |||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |||||
.addGroup(layout.createSequentialGroup() | |||||
.addContainerGap() | |||||
.addComponent(title) | |||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) | |||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) | |||||
.addComponent(titleLbl) | |||||
.addComponent(titleTxtField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) | |||||
.addGap(18, 18, 18) | |||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) | |||||
.addComponent(statusLbl) | |||||
.addComponent(statusComboBox, 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) | |||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) | |||||
.addComponent(createBtn) | |||||
.addComponent(cancelBtn)) | |||||
.addContainerGap()) | |||||
); | |||||
pack(); | |||||
}// </editor-fold>//GEN-END:initComponents | |||||
private void createBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_createBtnActionPerformed | |||||
status = statusOptions[statusComboBox.getSelectedIndex()]; | |||||
name = titleTxtField.getText(); | |||||
doClose(1); | |||||
}//GEN-LAST:event_createBtnActionPerformed | |||||
private void cancelBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelBtnActionPerformed | |||||
doClose(-1); | |||||
}//GEN-LAST:event_cancelBtnActionPerformed | |||||
private void doClose(int retStatus) { | |||||
returnStatus = retStatus; | |||||
setVisible(false); | |||||
dispose(); | |||||
} | |||||
/** | |||||
* @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(NewBookDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); | |||||
} catch (InstantiationException ex) { | |||||
java.util.logging.Logger.getLogger(NewBookDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); | |||||
} catch (IllegalAccessException ex) { | |||||
java.util.logging.Logger.getLogger(NewBookDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); | |||||
} catch (javax.swing.UnsupportedLookAndFeelException ex) { | |||||
java.util.logging.Logger.getLogger(NewBookDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); | |||||
} | |||||
//</editor-fold> | |||||
/* Create and display the dialog */ | |||||
java.awt.EventQueue.invokeLater(new Runnable() { | |||||
@Override | |||||
public void run() { | |||||
NewBookDialog dialog = new NewBookDialog(new javax.swing.JFrame(), true); | |||||
dialog.addWindowListener(new java.awt.event.WindowAdapter() { | |||||
@Override | |||||
public void windowClosing(java.awt.event.WindowEvent e) { | |||||
System.exit(0); | |||||
} | |||||
}); | |||||
dialog.setVisible(true); | |||||
} | |||||
}); | |||||
} | |||||
// Variables declaration - do not modify//GEN-BEGIN:variables | |||||
private javax.swing.JButton cancelBtn; | |||||
private javax.swing.JButton createBtn; | |||||
private javax.swing.JComboBox<String> statusComboBox; | |||||
private javax.swing.JLabel statusLbl; | |||||
private javax.swing.JLabel title; | |||||
private javax.swing.JLabel titleLbl; | |||||
private javax.swing.JTextField titleTxtField; | |||||
// End of variables declaration//GEN-END:variables | |||||
private int returnStatus = -1; | |||||
private String name; | |||||
private String status; | |||||
private String[] statusOptions = new String[] { "AVAILABLE", "NOT AVAILABLE", "RESERVED" }; | |||||
} |
@@ -28,7 +28,7 @@ | |||||
<Group type="103" groupAlignment="0" attributes="0"> | <Group type="103" groupAlignment="0" attributes="0"> | ||||
<Group type="102" alignment="0" attributes="0"> | <Group type="102" alignment="0" attributes="0"> | ||||
<Component id="createBtn" min="-2" max="-2" attributes="0"/> | <Component id="createBtn" min="-2" max="-2" attributes="0"/> | ||||
<EmptySpace pref="13" max="32767" attributes="0"/> | |||||
<EmptySpace max="32767" attributes="0"/> | |||||
<Component id="cancelBtn" min="-2" max="-2" attributes="0"/> | <Component id="cancelBtn" min="-2" max="-2" attributes="0"/> | ||||
</Group> | </Group> | ||||
<Group type="102" attributes="0"> | <Group type="102" attributes="0"> | ||||
@@ -36,7 +36,7 @@ | |||||
<Component id="title" alignment="0" min="-2" max="-2" attributes="0"/> | <Component id="title" alignment="0" min="-2" max="-2" attributes="0"/> | ||||
<Component id="errorLbl" alignment="0" min="-2" max="-2" attributes="0"/> | <Component id="errorLbl" alignment="0" min="-2" max="-2" attributes="0"/> | ||||
</Group> | </Group> | ||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/> | |||||
<EmptySpace min="0" pref="13" max="32767" attributes="0"/> | |||||
</Group> | </Group> | ||||
<Group type="102" alignment="0" attributes="0"> | <Group type="102" alignment="0" attributes="0"> | ||||
<Group type="103" groupAlignment="0" attributes="0"> | <Group type="103" groupAlignment="0" attributes="0"> | ||||
@@ -102,7 +102,7 @@ | |||||
</Component> | </Component> | ||||
<Component class="javax.swing.JButton" name="createBtn"> | <Component class="javax.swing.JButton" name="createBtn"> | ||||
<Properties> | <Properties> | ||||
<Property name="text" type="java.lang.String" value="Create user"/> | |||||
<Property name="text" type="java.lang.String" value="Add user"/> | |||||
</Properties> | </Properties> | ||||
<Events> | <Events> | ||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="createBtnActionPerformed"/> | <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="createBtnActionPerformed"/> | ||||
@@ -1,9 +1,5 @@ | |||||
package libsys; | package libsys; | ||||
/** | |||||
* | |||||
* @author binhonglee | |||||
*/ | |||||
public class NewUserDialog extends javax.swing.JDialog { | public class NewUserDialog extends javax.swing.JDialog { | ||||
/** | /** | ||||
@@ -13,18 +9,18 @@ public class NewUserDialog extends javax.swing.JDialog { | |||||
super(parent, modal); | super(parent, modal); | ||||
initComponents(); | initComponents(); | ||||
} | } | ||||
/** | /** | ||||
* @return the return status of this dialog - one of RET_OK or RET_CANCEL | * @return the return status of this dialog - one of RET_OK or RET_CANCEL | ||||
*/ | */ | ||||
public int getReturnStatus() { | public int getReturnStatus() { | ||||
return returnStatus; | return returnStatus; | ||||
} | } | ||||
public String getName() { | public String getName() { | ||||
return name; | return name; | ||||
} | } | ||||
public int getLimit() | public int getLimit() | ||||
{ | { | ||||
return limit; | return limit; | ||||
@@ -57,7 +53,7 @@ public class NewUserDialog extends javax.swing.JDialog { | |||||
limitLbl.setText("Limit :"); | limitLbl.setText("Limit :"); | ||||
createBtn.setText("Create user"); | |||||
createBtn.setText("Add user"); | |||||
createBtn.addActionListener(new java.awt.event.ActionListener() { | createBtn.addActionListener(new java.awt.event.ActionListener() { | ||||
public void actionPerformed(java.awt.event.ActionEvent evt) { | public void actionPerformed(java.awt.event.ActionEvent evt) { | ||||
createBtnActionPerformed(evt); | createBtnActionPerformed(evt); | ||||
@@ -83,13 +79,13 @@ public class NewUserDialog extends javax.swing.JDialog { | |||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | ||||
.addGroup(layout.createSequentialGroup() | .addGroup(layout.createSequentialGroup() | ||||
.addComponent(createBtn) | .addComponent(createBtn) | ||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 13, Short.MAX_VALUE) | |||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) | |||||
.addComponent(cancelBtn)) | .addComponent(cancelBtn)) | ||||
.addGroup(layout.createSequentialGroup() | .addGroup(layout.createSequentialGroup() | ||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | ||||
.addComponent(title) | .addComponent(title) | ||||
.addComponent(errorLbl)) | .addComponent(errorLbl)) | ||||
.addGap(0, 0, Short.MAX_VALUE)) | |||||
.addGap(0, 13, Short.MAX_VALUE)) | |||||
.addGroup(layout.createSequentialGroup() | .addGroup(layout.createSequentialGroup() | ||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | ||||
.addComponent(limitLbl) | .addComponent(limitLbl) | ||||
@@ -141,7 +137,7 @@ public class NewUserDialog extends javax.swing.JDialog { | |||||
private void cancelBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelBtnActionPerformed | private void cancelBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelBtnActionPerformed | ||||
doClose(-1); | doClose(-1); | ||||
}//GEN-LAST:event_cancelBtnActionPerformed | }//GEN-LAST:event_cancelBtnActionPerformed | ||||
private void doClose(int retStatus) { | private void doClose(int retStatus) { | ||||
returnStatus = retStatus; | returnStatus = retStatus; | ||||
setVisible(false); | setVisible(false); | ||||
@@ -155,7 +151,7 @@ public class NewUserDialog extends javax.swing.JDialog { | |||||
/* Set the Nimbus look and feel */ | /* Set the Nimbus look and feel */ | ||||
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> | //<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. | /* 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 | |||||
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html | |||||
*/ | */ | ||||
try { | try { | ||||
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { | for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { | ||||
@@ -4,17 +4,17 @@ package libsys; | |||||
* Last edited : 5/30/2017 | * Last edited : 5/30/2017 | ||||
*/ | */ | ||||
import java.util.List; | |||||
import java.util.ArrayList; | |||||
import org.json.JSONString; | |||||
import org.json.JSONObject; | |||||
import org.json.JSONTokener; | |||||
import org.json.JSONArray; | |||||
import java.io.FileInputStream; | |||||
import java.io.PrintWriter; | |||||
import java.io.File; | |||||
import java.util.Enumeration; | |||||
import java.io.Serializable; | |||||
import java.util.List; | |||||
import java.util.ArrayList; | |||||
import org.json.JSONString; | |||||
import org.json.JSONObject; | |||||
import org.json.JSONTokener; | |||||
import org.json.JSONArray; | |||||
import java.io.FileInputStream; | |||||
import java.io.PrintWriter; | |||||
import java.io.File; | |||||
import java.util.Enumeration; | |||||
import java.io.Serializable; | |||||
class UserFactory | class UserFactory | ||||
{ | { | ||||