repair payment form + add functionality
must be fully working
This commit is contained in:
		
							parent
							
								
									2a94b86ba0
								
							
						
					
					
						commit
						70110cb787
					
				
					 2 changed files with 201 additions and 54 deletions
				
			
		|  | @ -1,6 +1,14 @@ | ||||||
| <?xml version="1.0" encoding="UTF-8" ?> | <?xml version="1.0" encoding="UTF-8" ?> | ||||||
| 
 | 
 | ||||||
| <Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> | <Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> | ||||||
|  |   <Properties> | ||||||
|  |     <Property name="defaultCloseOperation" type="int" value="2"/> | ||||||
|  |     <Property name="title" type="java.lang.String" value="POSware Lite: Payment"/> | ||||||
|  |   </Properties> | ||||||
|  |   <SyntheticProperties> | ||||||
|  |     <SyntheticProperty name="formSizePolicy" type="int" value="1"/> | ||||||
|  |     <SyntheticProperty name="generateCenter" type="boolean" value="false"/> | ||||||
|  |   </SyntheticProperties> | ||||||
|   <AuxValues> |   <AuxValues> | ||||||
|     <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> |     <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> | ||||||
|     <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> |     <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> | ||||||
|  | @ -16,29 +24,6 @@ | ||||||
| 
 | 
 | ||||||
|   <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> |   <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> | ||||||
|   <SubComponents> |   <SubComponents> | ||||||
|     <Container class="javax.swing.JPanel" name="jPanel_actions"> |  | ||||||
|       <Constraints> |  | ||||||
|         <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> |  | ||||||
|           <BorderConstraints direction="Last"/> |  | ||||||
|         </Constraint> |  | ||||||
|       </Constraints> |  | ||||||
| 
 |  | ||||||
|       <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/> |  | ||||||
|       <SubComponents> |  | ||||||
|         <Component class="javax.swing.JButton" name="jButton_action_cancel"> |  | ||||||
|           <Properties> |  | ||||||
|             <Property name="text" type="java.lang.String" value="Cancel"/> |  | ||||||
|             <Property name="actionCommand" type="java.lang.String" value="action_cancel"/> |  | ||||||
|           </Properties> |  | ||||||
|         </Component> |  | ||||||
|         <Component class="javax.swing.JButton" name="jButton_action_continue"> |  | ||||||
|           <Properties> |  | ||||||
|             <Property name="text" type="java.lang.String" value="Complete"/> |  | ||||||
|             <Property name="actionCommand" type="java.lang.String" value="action_continue"/> |  | ||||||
|           </Properties> |  | ||||||
|         </Component> |  | ||||||
|       </SubComponents> |  | ||||||
|     </Container> |  | ||||||
|     <Container class="javax.swing.JPanel" name="jPanel_information"> |     <Container class="javax.swing.JPanel" name="jPanel_information"> | ||||||
|       <Constraints> |       <Constraints> | ||||||
|         <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> |         <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> | ||||||
|  | @ -80,7 +65,7 @@ | ||||||
|         </Component> |         </Component> | ||||||
|         <Component class="javax.swing.JLabel" name="jLabel_information_payment_value"> |         <Component class="javax.swing.JLabel" name="jLabel_information_payment_value"> | ||||||
|           <Properties> |           <Properties> | ||||||
|             <Property name="text" type="java.lang.String" value="jLabel1"/> |             <Property name="text" type="java.lang.String" value="Payment"/> | ||||||
|           </Properties> |           </Properties> | ||||||
|           <Constraints> |           <Constraints> | ||||||
|             <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> |             <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> | ||||||
|  | @ -95,6 +80,50 @@ | ||||||
|             </Constraint> |             </Constraint> | ||||||
|           </Constraints> |           </Constraints> | ||||||
|         </Component> |         </Component> | ||||||
|  |         <Component class="javax.swing.JLabel" name="jLabel_information_change"> | ||||||
|  |           <Properties> | ||||||
|  |             <Property name="text" type="java.lang.String" value="Change"/> | ||||||
|  |           </Properties> | ||||||
|  |           <Constraints> | ||||||
|  |             <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> | ||||||
|  |               <GridBagConstraints gridX="0" gridY="2" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/> | ||||||
|  |             </Constraint> | ||||||
|  |           </Constraints> | ||||||
|  |         </Component> | ||||||
|  |         <Component class="javax.swing.JTextField" name="jTextField1"> | ||||||
|  |           <Properties> | ||||||
|  |             <Property name="editable" type="boolean" value="false"/> | ||||||
|  |             <Property name="horizontalAlignment" type="int" value="11"/> | ||||||
|  |           </Properties> | ||||||
|  |           <Constraints> | ||||||
|  |             <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> | ||||||
|  |               <GridBagConstraints gridX="1" gridY="2" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="1.0" weightY="0.0"/> | ||||||
|  |             </Constraint> | ||||||
|  |           </Constraints> | ||||||
|  |         </Component> | ||||||
|  |       </SubComponents> | ||||||
|  |     </Container> | ||||||
|  |     <Container class="javax.swing.JPanel" name="jPanel_actions"> | ||||||
|  |       <Constraints> | ||||||
|  |         <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> | ||||||
|  |           <BorderConstraints direction="Last"/> | ||||||
|  |         </Constraint> | ||||||
|  |       </Constraints> | ||||||
|  | 
 | ||||||
|  |       <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/> | ||||||
|  |       <SubComponents> | ||||||
|  |         <Component class="javax.swing.JButton" name="jButton_action_cancel"> | ||||||
|  |           <Properties> | ||||||
|  |             <Property name="text" type="java.lang.String" value="Cancel"/> | ||||||
|  |             <Property name="actionCommand" type="java.lang.String" value="action_cancel"/> | ||||||
|  |           </Properties> | ||||||
|  |         </Component> | ||||||
|  |         <Component class="javax.swing.JButton" name="jButton_action_continue"> | ||||||
|  |           <Properties> | ||||||
|  |             <Property name="text" type="java.lang.String" value="Complete"/> | ||||||
|  |             <Property name="actionCommand" type="java.lang.String" value="action_continue"/> | ||||||
|  |           </Properties> | ||||||
|  |         </Component> | ||||||
|       </SubComponents> |       </SubComponents> | ||||||
|     </Container> |     </Container> | ||||||
|   </SubComponents> |   </SubComponents> | ||||||
|  |  | ||||||
|  | @ -1,52 +1,54 @@ | ||||||
| /* | /* | ||||||
|  * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license |  * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license | ||||||
|  * Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JPanel.java to edit this template |  * Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JDialog.java to edit this template | ||||||
|  */ |  */ | ||||||
| package tech.iBeans.POSware.Lite; | package tech.iBeans.POSware.Lite; | ||||||
| 
 | 
 | ||||||
|  | import java.awt.event.ActionEvent; | ||||||
|  | import java.awt.event.ActionListener; | ||||||
|  | import javax.swing.SpinnerNumberModel; | ||||||
|  | import javax.swing.event.ChangeEvent; | ||||||
|  | import javax.swing.event.ChangeListener; | ||||||
|  | 
 | ||||||
| /** | /** | ||||||
|  * |  * | ||||||
|  * @author eleven |  * @author eleven | ||||||
|  */ |  */ | ||||||
| public class OnPayment extends javax.swing.JPanel { | public class OnPayment extends javax.swing.JDialog { | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|      * Creates new form OnPayment |      * Creates new form Window_Payment | ||||||
|      */ |      */ | ||||||
|     public OnPayment() { |     public OnPayment(java.awt.Frame parent, boolean modal) { | ||||||
|  |         super(parent, modal); | ||||||
|         initComponents(); |         initComponents(); | ||||||
|     } |     } | ||||||
|      |      | ||||||
|  |     private static OnPayment dialog_payment = new OnPayment(new javax.swing.JFrame(), true); | ||||||
|  | 
 | ||||||
|     /** |     /** | ||||||
|      * This method is called from within the constructor to initialize the form. |      * 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 |      * WARNING: Do NOT modify this code. The content of this method is always | ||||||
|      * regenerated by the Form Editor. |      * regenerated by the Form Editor. | ||||||
|      */ |      */ | ||||||
|     @SuppressWarnings("unchecked") |      | ||||||
|     // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents |     // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents | ||||||
|     private void initComponents() { |     private void initComponents() { | ||||||
|         java.awt.GridBagConstraints gridBagConstraints; |         java.awt.GridBagConstraints gridBagConstraints; | ||||||
| 
 | 
 | ||||||
|         jPanel_actions = new javax.swing.JPanel(); |  | ||||||
|         jButton_action_cancel = new javax.swing.JButton(); |  | ||||||
|         jButton_action_continue = new javax.swing.JButton(); |  | ||||||
|         jPanel_information = new javax.swing.JPanel(); |         jPanel_information = new javax.swing.JPanel(); | ||||||
|         jLabel_information_total = new javax.swing.JLabel(); |         jLabel_information_total = new javax.swing.JLabel(); | ||||||
|         jTextField_information_total_value = new javax.swing.JTextField(); |         jTextField_information_total_value = new javax.swing.JTextField(); | ||||||
|         jLabel_information_payment_value = new javax.swing.JLabel(); |         jLabel_information_payment_value = new javax.swing.JLabel(); | ||||||
|         jSpinner_information_payment_value = new javax.swing.JSpinner(); |         jSpinner_information_payment_value = new javax.swing.JSpinner(); | ||||||
|  |         jLabel_information_change = new javax.swing.JLabel(); | ||||||
|  |         jTextField1 = new javax.swing.JTextField(); | ||||||
|  |         jPanel_actions = new javax.swing.JPanel(); | ||||||
|  |         jButton_action_cancel = new javax.swing.JButton(); | ||||||
|  |         jButton_action_continue = new javax.swing.JButton(); | ||||||
| 
 | 
 | ||||||
|         setLayout(new java.awt.BorderLayout()); |         setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); | ||||||
| 
 |         setTitle("POSware Lite: Payment"); | ||||||
|         jButton_action_cancel.setText("Cancel"); |  | ||||||
|         jButton_action_cancel.setActionCommand("action_cancel"); |  | ||||||
|         jPanel_actions.add(jButton_action_cancel); |  | ||||||
| 
 |  | ||||||
|         jButton_action_continue.setText("Complete"); |  | ||||||
|         jButton_action_continue.setActionCommand("action_continue"); |  | ||||||
|         jPanel_actions.add(jButton_action_continue); |  | ||||||
| 
 |  | ||||||
|         add(jPanel_actions, java.awt.BorderLayout.PAGE_END); |  | ||||||
| 
 | 
 | ||||||
|         jPanel_information.setLayout(new java.awt.GridBagLayout()); |         jPanel_information.setLayout(new java.awt.GridBagLayout()); | ||||||
| 
 | 
 | ||||||
|  | @ -70,7 +72,7 @@ public class OnPayment extends javax.swing.JPanel { | ||||||
|         gridBagConstraints.weightx = 1.0; |         gridBagConstraints.weightx = 1.0; | ||||||
|         jPanel_information.add(jTextField_information_total_value, gridBagConstraints); |         jPanel_information.add(jTextField_information_total_value, gridBagConstraints); | ||||||
| 
 | 
 | ||||||
|         jLabel_information_payment_value.setText("jLabel1"); |         jLabel_information_payment_value.setText("Payment"); | ||||||
|         gridBagConstraints = new java.awt.GridBagConstraints(); |         gridBagConstraints = new java.awt.GridBagConstraints(); | ||||||
|         gridBagConstraints.gridx = 0; |         gridBagConstraints.gridx = 0; | ||||||
|         gridBagConstraints.gridy = 1; |         gridBagConstraints.gridy = 1; | ||||||
|  | @ -80,20 +82,136 @@ public class OnPayment extends javax.swing.JPanel { | ||||||
|         gridBagConstraints.gridy = 1; |         gridBagConstraints.gridy = 1; | ||||||
|         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; | ||||||
|         gridBagConstraints.weightx = 1.0; |         gridBagConstraints.weightx = 1.0; | ||||||
|  |         jSpinner_information_payment_value.addChangeListener(new ChangeListener() { | ||||||
|  |             public void stateChanged(ChangeEvent e) { | ||||||
|  |                 getCompletable(); | ||||||
|  |             } | ||||||
|  |         }); | ||||||
|  |         jSpinner_information_payment_value.setModel(model_price); | ||||||
|         jPanel_information.add(jSpinner_information_payment_value, gridBagConstraints); |         jPanel_information.add(jSpinner_information_payment_value, gridBagConstraints); | ||||||
| 
 | 
 | ||||||
|         add(jPanel_information, java.awt.BorderLayout.CENTER); |         jLabel_information_change.setText("Change"); | ||||||
|  |         gridBagConstraints = new java.awt.GridBagConstraints(); | ||||||
|  |         gridBagConstraints.gridx = 0; | ||||||
|  |         gridBagConstraints.gridy = 2; | ||||||
|  |         jPanel_information.add(jLabel_information_change, gridBagConstraints); | ||||||
|  | 
 | ||||||
|  |         jTextField1.setEditable(false); | ||||||
|  |         jTextField1.setHorizontalAlignment(javax.swing.JTextField.TRAILING); | ||||||
|  |         gridBagConstraints = new java.awt.GridBagConstraints(); | ||||||
|  |         gridBagConstraints.gridx = 1; | ||||||
|  |         gridBagConstraints.gridy = 2; | ||||||
|  |         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; | ||||||
|  |         gridBagConstraints.weightx = 1.0; | ||||||
|  |         jPanel_information.add(jTextField1, gridBagConstraints); | ||||||
|  | 
 | ||||||
|  |         getContentPane().add(jPanel_information, java.awt.BorderLayout.CENTER); | ||||||
|  | 
 | ||||||
|  |         jButton_action_cancel.setText("Cancel"); | ||||||
|  |         jButton_action_cancel.addActionListener(setCancelled); | ||||||
|  |         jPanel_actions.add(jButton_action_cancel); | ||||||
|  | 
 | ||||||
|  |         jButton_action_continue.setText("Complete"); | ||||||
|  |         jButton_action_continue.addActionListener(setCompleted); | ||||||
|  |         jPanel_actions.add(jButton_action_continue); | ||||||
|  | 
 | ||||||
|  |         getContentPane().add(jPanel_actions, java.awt.BorderLayout.PAGE_END); | ||||||
|  | 
 | ||||||
|  |         pack(); | ||||||
|     }// </editor-fold>//GEN-END:initComponents |     }// </editor-fold>//GEN-END:initComponents | ||||||
| 
 | 
 | ||||||
|      |      | ||||||
|  | 
 | ||||||
|     // Variables declaration - do not modify//GEN-BEGIN:variables |     // Variables declaration - do not modify//GEN-BEGIN:variables | ||||||
|     private javax.swing.JButton jButton_action_cancel; |     private static javax.swing.JButton jButton_action_cancel; | ||||||
|     private javax.swing.JButton jButton_action_continue; |     private static javax.swing.JButton jButton_action_continue; | ||||||
|     private javax.swing.JLabel jLabel_information_payment_value; |     private static javax.swing.JLabel jLabel_information_change; | ||||||
|     private javax.swing.JLabel jLabel_information_total; |     private static javax.swing.JLabel jLabel_information_payment_value; | ||||||
|     private javax.swing.JPanel jPanel_actions; |     private static javax.swing.JLabel jLabel_information_total; | ||||||
|     private javax.swing.JPanel jPanel_information; |     private static javax.swing.JPanel jPanel_actions; | ||||||
|     private javax.swing.JSpinner jSpinner_information_payment_value; |     private static javax.swing.JPanel jPanel_information; | ||||||
|     private javax.swing.JTextField jTextField_information_total_value; |     private static javax.swing.JSpinner jSpinner_information_payment_value; | ||||||
|  |     private static javax.swing.JTextField jTextField1; | ||||||
|  |     private static javax.swing.JTextField jTextField_information_total_value; | ||||||
|     // End of variables declaration//GEN-END:variables |     // End of variables declaration//GEN-END:variables | ||||||
|  |      | ||||||
|  |     public static Boolean display() { | ||||||
|  | 		/* Display the transaction. */ | ||||||
|  | 		dialog_payment.setModal(true); | ||||||
|  |                 dialog_payment.addWindowListener(new java.awt.event.WindowAdapter() { | ||||||
|  |                     @Override | ||||||
|  |                     public void windowClosing(java.awt.event.WindowEvent e) { | ||||||
|  |                         // Reflect a cancelled payment.  | ||||||
|  | 			payment.state = false; | ||||||
|  |                         e.getWindow().dispose(); | ||||||
|  |                     } | ||||||
|  |                 }); | ||||||
|  |                 getCompletable(); | ||||||
|  | 		dialog_payment.setVisible(true); | ||||||
|  | 		return(payment.state); | ||||||
|  | 	}; | ||||||
|  | 
 | ||||||
|  | 	// Set the numerical model.  | ||||||
|  | 	private SpinnerNumberModel model_price = new SpinnerNumberModel(0, 0, Integer.MAX_VALUE, .01); | ||||||
|  | 
 | ||||||
|  | 	// Window events | ||||||
|  | 	private static void getCompletable() { | ||||||
|  | 		float in = Float.parseFloat(String.valueOf(jSpinner_information_payment_value.getValue())); | ||||||
|  | 		 | ||||||
|  | 		// Calculate the value.  | ||||||
|  | 		payment.calculate(in); | ||||||
|  | 		setCompletable(); | ||||||
|  | 		update(); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private static boolean setCompletable() { | ||||||
|  | 		/* Calculate whether the change is sufficient. */ | ||||||
|  | 		setCompletable(payment.OK); | ||||||
|  | 		 | ||||||
|  | 		return (payment.OK); | ||||||
|  | 	}; | ||||||
|  | 
 | ||||||
|  | 	private static boolean setCompletable(boolean STATE) { | ||||||
|  | 		/* Calculate whether the change is sufficient. */ | ||||||
|  | 		jButton_action_continue.setEnabled(STATE); | ||||||
|  | 
 | ||||||
|  | 		if (STATE) { | ||||||
|  | 			dialog_payment.getRootPane().setDefaultButton(jButton_action_continue); | ||||||
|  | 		} else { | ||||||
|  | 			dialog_payment.getRootPane().setDefaultButton(jButton_action_cancel); | ||||||
|  | 		}; | ||||||
|  | 
 | ||||||
|  | 		return (STATE); | ||||||
|  | 	}; | ||||||
|  | 
 | ||||||
|  | 	ActionListener setCompleted = new ActionListener() { | ||||||
|  | 		@Override | ||||||
|  | 		public void actionPerformed(ActionEvent e) { | ||||||
|  | 			payment.OK = true; | ||||||
|  | 			payment.state = true; | ||||||
|  | 			dispose(); | ||||||
|  | 		}; | ||||||
|  | 	}; | ||||||
|  | 
 | ||||||
|  | 	ActionListener setCancelled = new ActionListener() { | ||||||
|  | 		@Override | ||||||
|  | 		public void actionPerformed(ActionEvent e) { | ||||||
|  | 			payment.OK = false; | ||||||
|  | 			payment.state = false; | ||||||
|  | 			dispose(); | ||||||
|  | 		}; | ||||||
|  | 	}; | ||||||
|  | 
 | ||||||
|  | 	 | ||||||
|  | 	// Update information.  | ||||||
|  | 	public static void update() { | ||||||
|  | 		/* Update the information. */ | ||||||
|  | 		if (payment.total != null) { | ||||||
|  | 			jTextField_information_total_value.setText(String.valueOf(payment.total)); | ||||||
|  | 		}; | ||||||
|  | 		if (payment.change != null) { | ||||||
|  | 			jTextField1.setText(String.valueOf(payment.change)); | ||||||
|  | 		}; | ||||||
|  | 	}; | ||||||
|  | 
 | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue