📄 supplierframe.java
字号:
.add(JPane2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jLabel6)
.add(jLabel3))
.add(jLabel7))
.add(23, 23, 23)
.add(JPane2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(txtSupplierName, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 190, Short.MAX_VALUE)
.add(txtOwer, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 190, Short.MAX_VALUE)
.add(txtPhone, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 190, Short.MAX_VALUE))))))
.add(4, 4, 4)
.add(EixtButton)
.add(20, 20, 20))
);
JPane2Layout.setVerticalGroup(
JPane2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(JPane2Layout.createSequentialGroup()
.add(21, 21, 21)
.add(JPane2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel1)
.add(jLabel6)
.add(txtSupplierID, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(txtSupplierName, 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(JPane2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel2)
.add(txtOwerPost, 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(JPane2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel4)
.add(txtMobilePhone, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jLabel7)
.add(txtPhone, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(8, 8, 8)
.add(JPane2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel5)
.add(txtSupplierAddress, 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(JPane2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(ReworkButton)
.add(AddButton)
.add(EixtButton)
.add(Buttonsave)
.add(DeleteButton)
.add(jButton5))
.addContainerGap(55, Short.MAX_VALUE))
);
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(layout.createSequentialGroup()
.add(JPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.add(10, 10, 10))
.add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 704, Short.MAX_VALUE)))
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addContainerGap()
.add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 306, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(JPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void DeleteButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_DeleteButtonActionPerformed
// TODO 将在此处添加您的处理代码:
settxt();
if(txtSupplierID.getText().trim().length()>0&&add_pasre==false&&reset_pasre==false)
{
s.setSupplierID(txtSupplierID.getText());
if(hu.isDelete(s)){
int n=JOptionPane.showConfirmDialog(this,"删除之后信息将不可恢复,确定要删除吗?","",JOptionPane.OK_CANCEL_OPTION,JOptionPane.WARNING_MESSAGE);
if(n==JOptionPane.OK_OPTION)
{
hu.delete(s);
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 ReworkButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ReworkButtonActionPerformed
// TODO 将在此处添加您的处理代码:
if(txtSupplierID.getText().trim().length()>0&&add_pasre==false)
{
reset_pasre=true;
add_pasre=false;
//将文本框设为可编辑
dissettxt();
}
else{
settxt();
JOptionPane.showMessageDialog(this,"请在表里选择要修改的项!","",JOptionPane.WARNING_MESSAGE);
}
}//GEN-LAST:event_ReworkButtonActionPerformed
private void ButtonsaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ButtonsaveActionPerformed
// TODO 将在此处添加您的处理代码:
if(add_pasre==true||reset_pasre==true&&txtSupplierID.getText().trim().length()>0)
{
settxt();
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();
settxt();
}
else
JOptionPane.showMessageDialog(this,"没有任何操作需要保存!","",JOptionPane.WARNING_MESSAGE);
}//GEN-LAST:event_ButtonsaveActionPerformed
private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable1MouseClicked
// TODO 将在此处添加您的处理代码:
settxt();
reset_pasre=false;
add_pasre=false;
int i=jTable1.getSelectedRow();
Supplier s=new Supplier();
s=(Supplier)v.get(i);
txtSupplierID.setText(s.getSupplierID());
txtSupplierName.setText(s.getSupplierName());
txtOwer.setText(s.getOwer());
txtOwerPost.setText(s.getOwerPost());
txtPhone.setText(s.getPhone());
txtMobilePhone.setText(s.getMobilePhone());
txtSupplierAddress.setText(s.getSupplierAddress());
}//GEN-LAST:event_jTable1MouseClicked
private void EixtButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_EixtButtonActionPerformed
// TODO 将在此处添加您的处理代码:
if(reset_pasre==true||add_pasre==true&&txtSupplierID.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("SupplierFrame");
}
}
else{
this.dispose();
ConstentUtil.hashtable.remove("SupplierFrame");
}
}//GEN-LAST:event_EixtButtonActionPerformed
private void AddButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AddButtonActionPerformed
//点击增加,将变量add_pasre设为true
reset_pasre=false;
add_pasre=true;
clear();
txtSupplierID.setEditable(true);
dissettxt();
}//GEN-LAST:event_AddButtonActionPerformed
// 变量声明 - 不进行修改//GEN-BEGIN:variables
private javax.swing.JButton AddButton;
private javax.swing.JButton Buttonsave;
private javax.swing.JButton DeleteButton;
private javax.swing.JButton EixtButton;
private javax.swing.JPanel JPane2;
private javax.swing.JButton ReworkButton;
private javax.swing.JButton jButton5;
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.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTable jTable1;
private javax.swing.JTextField txtMobilePhone;
private javax.swing.JTextField txtOwer;
private javax.swing.JTextField txtOwerPost;
private javax.swing.JTextField txtPhone;
private javax.swing.JTextField txtSupplierAddress;
private javax.swing.JTextField txtSupplierID;
private javax.swing.JTextField txtSupplierName;
// 变量声明结束//GEN-END:variables
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -