📄 third2.java
字号:
/*
* third2.java
*
* Created on 2006年9月27日, 上午11:21
*/
package account2;
/**
*
* @author Administrator
*/
import javax.swing.JOptionPane;
public class third2 extends javax.swing.JFrame {
/** Creates new form third2 */
public third2() {
initComponents();
Customer cus = new Customer();
int num = cus.getSum();
String name = cus.getCustomer_name();
int account_num[]= new int[num];
int j = 0;
for(int i = 0;i<num;i++){
if(cus.a[i].getCustomer_name().equals(name)){
account_num[j] = cus.a[i].getAccount_id();
jComboBox1.addItem(account_num[j]);
j++;
}
}
}
/** 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.
*/
// <editor-fold defaultstate="collapsed" desc=" 生成的代码 ">//GEN-BEGIN:initComponents
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jComboBox1 = new javax.swing.JComboBox();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jTextField1 = new javax.swing.JTextField();
jTextField2 = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
jLabel4 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("\u5e10\u6237\u7ba1\u7406"));
jLabel1.setFont(new java.awt.Font("宋体", 1, 14));
jLabel1.setForeground(new java.awt.Color(0, 51, 255));
jLabel1.setText("\u8bf7\u9009\u62e9\u5e10\u6237:");
jLabel1.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
jComboBox1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jComboBox1ActionPerformed(evt);
}
});
jLabel2.setFont(new java.awt.Font("宋体", 1, 14));
jLabel2.setForeground(new java.awt.Color(0, 51, 255));
jLabel2.setText("\u8f93\u5165\u5b58\u6b3e\u91d1\u989d:");
jLabel2.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
jLabel3.setFont(new java.awt.Font("宋体", 1, 14));
jLabel3.setForeground(new java.awt.Color(0, 102, 255));
jLabel3.setText("\u8f93\u5165\u53d6\u6b3e\u91d1\u989d:");
jLabel3.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
jTextField1.setText("0");
jTextField2.setText("0");
jButton1.setText("\u786e\u5b9a");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jButton2.setText("\u4e0a\u4e00\u6b65");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
jButton3.setText("\u8fd4\u56de");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
jLabel4.setText("\u8bf4\u660e:\u5982\u679c\u60f3\u770b\u4f59\u989d,\u9009\u62e9\u5e10\u6237\u540e\u76f4\u63a5\u70b9\u51fb\u786e\u5b9a\u6309\u94ae\u53ef\u4ee5\u67e5\u770b\u4f59\u989d!");
org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel1Layout.createSequentialGroup()
.add(71, 71, 71)
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(jPanel1Layout.createSequentialGroup()
.add(jButton3)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jButton2)
.add(19, 19, 19)
.add(jButton1))
.add(jPanel1Layout.createSequentialGroup()
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 86, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jLabel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 106, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jLabel3))
.add(8, 8, 8)
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
.add(jTextField2)
.add(jTextField1)
.add(jComboBox1, 0, 96, Short.MAX_VALUE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 95, Short.MAX_VALUE)))
.add(133, 133, 133))
.add(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.add(jLabel4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 489, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel1Layout.createSequentialGroup()
.addContainerGap()
.add(jLabel4)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 25, Short.MAX_VALUE)
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 32, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jComboBox1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 32, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(24, 24, 24)
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jLabel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 30, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jTextField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 33, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(13, 13, 13)
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(jLabel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 32, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jTextField2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 35, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(22, 22, 22)
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jButton2)
.add(jButton3)
.add(jButton1))
.add(35, 35, 35))
);
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
Customer cus = new Customer();
int num = cus.getSum();
String name = cus.getCustomer_name();
try{
Integer it = (Integer)jComboBox1.getSelectedItem();
int id = it.intValue();
double sub_money =Double.parseDouble((String) jTextField2.getText());
double add_money =Double.parseDouble((String) jTextField1.getText());
for(int k = 0;k<num;k++){
if(cus.a[k].getAccount_id()==id){
cus.a[k].setBalace(add_money);
if(!cus.a[k].subBalace(sub_money)){
JOptionPane.showMessageDialog(this,"你的余额不够!");
}
else{
JOptionPane.showMessageDialog(this,"操作已完成,你的帐户"+id+"金额为:"+cus.a[k].getBalance());
}
break;
}
}
jTextField2.setText("0");
jTextField1.setText("0");
}
catch(Exception e){
JOptionPane.showMessageDialog(this,"输入格式不正确!请检查!");
}
}//GEN-LAST:event_jButton1ActionPerformed
private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox1ActionPerformed
// TODO 将在此处添加您的处理代码:
}//GEN-LAST:event_jComboBox1ActionPerformed
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
third th = new third();
th.pack();
th.setVisible(true);
this.setVisible(false);
}//GEN-LAST:event_jButton2ActionPerformed
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
first f = new first();
f.pack();
f.setVisible(true);
this.setVisible(false);
}//GEN-LAST:event_jButton3ActionPerformed
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new third2().setVisible(true);
}
});
}
// 变量声明 - 不进行修改//GEN-BEGIN:variables
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JComboBox jComboBox1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JPanel jPanel1;
private javax.swing.JTextField jTextField1;
private javax.swing.JTextField jTextField2;
// 变量声明结束//GEN-END:variables
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -