customerframe.java
来自「基于mvc的java进销存系统」· Java 代码 · 共 419 行 · 第 1/2 页
JAVA
419 行
.add(27, 27, 27)
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel1)
.add(txtCustomerID, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jLabel3)
.add(txtOwer, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel2)
.add(txtCustomerName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(txtMobilePhone, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jLabel4)))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel5)
.add(txtCustomerAddress, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(21, 21, 21)
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(ReworkButton)
.add(AddButton)
.add(ExitButton)
.add(DeleteButton)
.add(PrintButton)
.add(SeveButton))
.addContainerGap())
);
jTable1.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null, null, null, null},
{null, null, null, null, null, null, null},
{null, null, null, null, null, null, null},
{null, null, null, null, null, null, null}
},
new String [] {
"标题 1", "标题 2", "标题 3", "标题 4", "标题 5", "标题 6", "标题 7"
}
) {
boolean[] canEdit = new boolean [] {
true, true, true, true, true, true, false
};
public boolean isCellEditable(int rowIndex, int columnIndex) {
return canEdit [columnIndex];
}
});
jTable1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jTable1MouseClicked(evt);
}
});
jScrollPane1.setViewportView(jTable1);
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addContainerGap()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 710, Short.MAX_VALUE)
.add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 290, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 50, Short.MAX_VALUE)
.add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void SeveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SeveButtonActionPerformed
// TODO 将在此处添加您的处理代码:
if((reset_pasre==true||add_pasre==true)&&txtCustomerID.getText().trim().length()>0)
{
dissettxt();
if(add_pasre==true)
{
save();
JOptionPane.showMessageDialog(this,"保存成功!","",JOptionPane.WARNING_MESSAGE);
databind();
add_pasre=false;
}
if(reset_pasre==true)
{
rework();
JOptionPane.showMessageDialog(this,"修改成功!","",JOptionPane.WARNING_MESSAGE);
databind();
reset_pasre=false;
}
clear();
dissettxt();
}
else
JOptionPane.showMessageDialog(this,"没有任何操作需要保存!","",JOptionPane.WARNING_MESSAGE);
}//GEN-LAST:event_SeveButtonActionPerformed
private void ExitButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ExitButtonActionPerformed
// TODO 将在此处添加您的处理代码:
if(reset_pasre==true||add_pasre==true&&txtCustomerID.getText().trim().length()>0){
int n=JOptionPane.showConfirmDialog(this,"有未完成的操作,确定要退出吗?","",JOptionPane.OK_CANCEL_OPTION,JOptionPane.WARNING_MESSAGE);
if(n==JOptionPane.OK_OPTION){
this.dispose();
ConstentUtil.hashtable.remove("CustomerFrame");
}
}
else{
this.dispose();
ConstentUtil.hashtable.remove("CustomerFrame");
}
}//GEN-LAST:event_ExitButtonActionPerformed
private void DeleteButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_DeleteButtonActionPerformed
// TODO 将在此处添加您的处理代码:
dissettxt();
if(txtCustomerID.getText().trim().length()>0&&add_pasre==false&&reset_pasre==false)
{
c.setCustomerID(txtCustomerID.getText());
if(hu.isDelete(c)){
int n=JOptionPane.showConfirmDialog(this,"删除之后信息将不可恢复,确定要删除吗?","",JOptionPane.OK_CANCEL_OPTION,JOptionPane.WARNING_MESSAGE);
if(n==JOptionPane.OK_OPTION)
{
hu.delete(c);
JOptionPane.showMessageDialog(this,"删除成功!","",JOptionPane.WARNING_MESSAGE);
databind();
clear();
}
}
else
JOptionPane.showMessageDialog(this,"不能删除!","",JOptionPane.WARNING_MESSAGE);
}
else{
clear();
JOptionPane.showMessageDialog(this,"请选择要删除的项!","",JOptionPane.WARNING_MESSAGE);
}
}//GEN-LAST:event_DeleteButtonActionPerformed
private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable1MouseClicked
// TODO 将在此处添加您的处理代码:
//获得选中的table行号
dissettxt();
reset_pasre=false;
add_pasre=false;
int i=jTable1.getSelectedRow();
c=(Customer)v.get(i);
txtCustomerID.setText(c.getCustomerID());
txtCustomerName.setText(c.getCustomerName());
txtOwer.setText(c.getOwer());
txtMobilePhone.setText(c.getMobilePhone().trim());
txtCustomerAddress.setText( c.getCustomerAddress());
}//GEN-LAST:event_jTable1MouseClicked
private void ReworkButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ReworkButtonActionPerformed
// TODO 将在此处添加您的处理代码:
if(txtCustomerID.getText().trim().length()>0&&add_pasre==false)
{
reset_pasre=true;
add_pasre=false;
//将文本框设为可编辑
settxt();
}
else{
clear();
dissettxt();
JOptionPane.showMessageDialog(this,"请在表里选择要修改的项!","",JOptionPane.WARNING_MESSAGE);
}
}//GEN-LAST:event_ReworkButtonActionPerformed
private void AddButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AddButtonActionPerformed
// TODO 将在此处添加您的处理代码:
reset_pasre=false;
add_pasre=true;
clear();
txtCustomerID.setEditable(true);
settxt();
}//GEN-LAST:event_AddButtonActionPerformed
// 变量声明 - 不进行修改//GEN-BEGIN:variables
private javax.swing.JButton AddButton;
private javax.swing.JButton DeleteButton;
private javax.swing.JButton ExitButton;
private javax.swing.JButton PrintButton;
private javax.swing.JButton ReworkButton;
private javax.swing.JButton SeveButton;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JPanel jPanel1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTable jTable1;
private javax.swing.JTextField txtCustomerAddress;
private javax.swing.JTextField txtCustomerID;
private javax.swing.JTextField txtCustomerName;
private javax.swing.JTextField txtMobilePhone;
private javax.swing.JTextField txtOwer;
// 变量声明结束//GEN-END:variables
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?