基于java实现停车场管理系统

本文实例为大家分享了java停车场管理系统的具体代码,供大家参考,具体内容如下

WorkFram.java

package com.parking;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;

/*
 * WotkFram.java
 *
 * Created on 2008年9月2日, 下午7:57
 */

/**
 *
 * @author cheng
 */
public class WorkFram extends JFrame {

 /**
 *
 */
 private static final long serialVersionUID = 1L;

 /**
  * @param args the command line arguments
  */
 // 变量声明 - 不进行修改//GEN-BEGIN:variables

 private JButton jbtnEnter;

 private JButton jbtnRefrush;

 private JTextArea jtexInfor;

 public int m_areaCount; //停车区个数

 public int[] m_nos;  //每个停车区的车位数

 public int[] m_apare; //每个停车区的空闲车位数

 // 变量声明结束//GEN-END:variables
 //int m_areaCount;

 /** Creates new form WotkFram */

 public WorkFram(InitFrame frm) {

  this.m_areaCount = frm.m_Area.length;
  this.m_apare = new int[m_areaCount];
  this.m_nos = new int[m_areaCount];
  for(int i = 0; i < m_areaCount; i++){
   this.m_apare[i] = frm.m_Area[i];
   this.m_nos[i] = frm.m_Area[i];
  }

  initComponents();
 }

 /** 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() {

  jbtnEnter = new JButton();

  jbtnRefrush = new JButton();

  jtexInfor = new JTextArea("停车场初始化结果:\n" + getStopStatus());

  jtexInfor.setEnabled(false);

  setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

  setTitle("\u505c\u8f66\u573a\u6a21\u62df");

  jbtnEnter.setText("\u8fdb\u5165\u505c\u8f66\u573a");

  jbtnRefrush.setText("刷新");

  jbtnEnter.addActionListener(new ActionListener() {
   public void actionPerformed(ActionEvent evt) {
    jbtnEnterActionPerformed(evt);
   }
  });

  jbtnRefrush.addActionListener(new ActionListener() {
   public void actionPerformed(ActionEvent evt) {
    jbtnRefrushActionPerformed(evt);
   }
  });

  GroupLayout layout = new GroupLayout(getContentPane());

  getContentPane().setLayout(layout);

  layout.setHorizontalGroup(
   layout.createParallelGroup(GroupLayout.Alignment.LEADING)
   .addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
    .addContainerGap(159, Short.MAX_VALUE)
    .addComponent(jtexInfor)
    .addComponent(jbtnRefrush)
    .addComponent(jbtnEnter)
    .addGap(128, 128, 128))
  );

  layout.setVerticalGroup(
   layout.createParallelGroup(GroupLayout.Alignment.LEADING)
   .addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
    .addContainerGap(204, Short.MAX_VALUE)
    .addComponent(jtexInfor)
    .addComponent(jbtnRefrush)
    .addComponent(jbtnEnter)
    .addGap(73, 73, 73))
  );

  pack();

 }// </editor-fold>//GEN-END:initComponents

 private void jbtnEnterActionPerformed(ActionEvent evt) {//GEN-FIRST:event_jbtnEnterActionPerformed
// TODO 将在此处添加您的处理代码:
  Thread thr = new carThread(this);
  thr.run();
 }//GEN-LAST:event_jbtnEnterActionPerformed

 private void jbtnRefrushActionPerformed(ActionEvent evt) {//GEN-FIRST:event_jbtnEnterActionPerformed
//  TODO 将在此处添加您的处理代码:
  this.jtexInfor.setText("停车场当前车区车位状况统计:\n" + getStopStatus());
 }//GEN-LAST:event_jbtnEnterActionPerformed

 public String getStopStatus() {
  String str = "";
  for (int i = 0; i < m_areaCount; i++) {
  if (m_apare[i] > 0) {
  str += " " + (i + 1) + " 区总车位:" + m_nos[i] + "\t当前空闲车位 " + m_apare[i] + " 个\n";
  } else {
  str += " " + (i + 1) + " 区总车位:" + m_nos[i] + "\t当前区无空闲车位\n";
  }
  }
  return str;
 }

 public void setInfor(String infor) {
  this.jtexInfor.setText(infor);
 }

}

InitFrame.java

package com.parking;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.*;
/*
 * InitFrame.java
 *
 * Created on 2008年9月2日, 下午7:36
 */

/**
 *
 * @author cheng
 */
public class InitFrame extends JFrame {

 // 变量声明 - 不进行修改
 //GEN-BEGIN:variables

 /**
 *
 */
 private static final long serialVersionUID = 1L;

 private JButton jButton1;

 private JLabel jLabel1;

 private JLabel jLabel2;

 private JLabel jLabel3;

 private JSpinner jSpinnerStopArea;

 private JButton jbtnCancel;

 private JButton jbtnOK;

 public JButton jbtnStopCount;

 private JTextField jtxtCarCount;

 private JTextField jtxtStopCount;

 public int m_Area[];

 SpinnerNumberModel mdl;

 // 变量声明结束//GEN-END:variables
 /** Creates new form InitFrame */
 public InitFrame() {
  initComponents();
  mdl = new SpinnerNumberModel();
  this.jSpinnerStopArea.setModel(mdl);
 }

 /** 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() { 

  jLabel1 = new JLabel();
  jtxtStopCount = new JTextField();
  jbtnStopCount = new JButton();
  jLabel2 = new JLabel();
  jSpinnerStopArea = new JSpinner();
  jLabel3 = new JLabel();
  jtxtCarCount = new JTextField();
  jButton1 = new JButton();
  jbtnOK = new JButton();
  jbtnCancel = new JButton();

  setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

  setTitle("\u505c\u8f66\u573a\u521d\u59cb\u5316");

  addWindowListener(new WindowAdapter() {
   public void windowClosing(WindowEvent evt) {
    formWindowClosing(evt);
   }
  });

  jLabel1.setText("\u505c\u8f66\u533a\u57df\u4e2a\u6570\uff1a");

  jbtnStopCount.setText("\u8f93\u5165\u505c\u533a\u4e2a\u6570");

  jbtnStopCount.addActionListener(new ActionListener() {
   public void actionPerformed(ActionEvent evt) {
    jbtnStopCountActionPerformed(evt);
   }
  });

  jLabel2.setText("\u505c\u8f66\u533a\u53f7\uff1a");

  jSpinnerStopArea.setEnabled(false);

  jLabel3.setText("\u505c\u8f66\u4f4d\u4e2a\u6570\uff1a");

  jtxtCarCount.setEnabled(false);

  jButton1.setText("\u8f93\u5165\u505c\u533a\u8f66\u4f4d\u4e2a\u6570");

  jButton1.addActionListener(new ActionListener() {
   public void actionPerformed(ActionEvent evt) {
    jButton1ActionPerformed(evt);
   }
  });

  jbtnOK.setText("\u786e\u5b9a");

  jbtnOK.setEnabled(false);

  jbtnOK.addActionListener(new ActionListener() {
   public void actionPerformed(ActionEvent evt) {
    jbtnOKActionPerformed(evt);
   }
  });

  jbtnCancel.setText("\u53d6\u6d88");

  jbtnCancel.addActionListener(new ActionListener() {
   public void actionPerformed(ActionEvent evt) {
    jbtnCancelActionPerformed(evt);
   }
  });

  GroupLayout layout = new GroupLayout(getContentPane());

  getContentPane().setLayout(layout);

  layout.setHorizontalGroup(
   layout.createParallelGroup(GroupLayout.Alignment.LEADING)
   .addGroup(layout.createSequentialGroup()
    .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
     .addGroup(layout.createSequentialGroup()
      .addContainerGap()
      .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
       .addGroup(layout.createSequentialGroup()
        .addComponent(jLabel2)
        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
        .addComponent(jSpinnerStopArea, GroupLayout.PREFERRED_SIZE, 37, GroupLayout.PREFERRED_SIZE)
        .addGap(14, 14, 14)
        .addComponent(jLabel3, GroupLayout.PREFERRED_SIZE, 81, GroupLayout.PREFERRED_SIZE)
        .addGap(13, 13, 13)
        .addComponent(jtxtCarCount, GroupLayout.PREFERRED_SIZE, 117, GroupLayout.PREFERRED_SIZE))
       .addGroup(layout.createSequentialGroup()
        .addComponent(jLabel1)
        .addGap(24, 24, 24)
        .addComponent(jtxtStopCount, GroupLayout.PREFERRED_SIZE, 99, GroupLayout.PREFERRED_SIZE)
        .addGap(25, 25, 25)
        .addComponent(jbtnStopCount))))
     .addGroup(layout.createSequentialGroup()
      .addGap(29, 29, 29)
      .addComponent(jButton1, GroupLayout.DEFAULT_SIZE, 137, Short.MAX_VALUE)
      .addGap(22, 22, 22)
      .addComponent(jbtnOK, GroupLayout.DEFAULT_SIZE, 65, Short.MAX_VALUE)
      .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
      .addComponent(jbtnCancel, GroupLayout.PREFERRED_SIZE, 66, GroupLayout.PREFERRED_SIZE)
      .addGap(23, 23, 23)))
    .addGap(51, 51, 51))
  );

  layout.setVerticalGroup(
   layout.createParallelGroup(GroupLayout.Alignment.LEADING)
   .addGroup(layout.createSequentialGroup()
    .addGap(30, 30, 30)
    .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
     .addComponent(jLabel1)
     .addComponent(jtxtStopCount, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
     .addComponent(jbtnStopCount))
    .addGap(27, 27, 27)
    .addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
     .addComponent(jLabel2)
     .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
      .addComponent(jSpinnerStopArea, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE)
      .addComponent(jLabel3, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE)
      .addComponent(jtxtCarCount, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
    .addGap(76, 76, 76)
    .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
     .addComponent(jButton1)
     .addComponent(jbtnOK)
     .addComponent(jbtnCancel))
    .addContainerGap(100, Short.MAX_VALUE))
  );

  pack();

 }// </editor-fold>//GEN-END:initComponents

 private void jbtnCancelActionPerformed(ActionEvent evt) {// GEN-FIRST:event_jbtnCancelActionPerformed
 // TODO 将在此处添加您的处理代码:
 JOptionPane.showMessageDialog(null, "您没有初始化,无法执行");
 System.exit(-1);
 }// GEN-LAST:event_jbtnCancelActionPerformed

 private void jbtnOKActionPerformed(ActionEvent evt) {// GEN-FIRST:event_jbtnOKActionPerformed
 // TODO 将在此处添加您的处理代码:
 this.setVisible(false);
 this.removeNotify();
 WorkFram frm = new WorkFram(this);
// setValue(frm);
 frm.setVisible(true);
 }// GEN-LAST:event_jbtnOKActionPerformed

 private void formWindowClosing(WindowEvent evt) {// GEN-FIRST:event_formWindowClosing
 // TODO 将在此处添加您的处理代码:
 JOptionPane.showMessageDialog(null, "您没有初始化,无法执行");
 System.exit(-1);
 }// GEN-LAST:event_formWindowClosing

 private void jButton1ActionPerformed(ActionEvent evt) {// GEN-FIRST:event_jButton1ActionPerformed
 // TODO 将在此处添加您的处理代码:
 boolean b = true;
 int n = ((Integer) mdl.getValue()).intValue() - 1;
 this.m_Area[n] = Integer.parseInt(this.jtxtCarCount.getText());
 for (int i = 0; i < m_Area.length; i++) {
 if (m_Area[i] <= 0) {
 b = false;

 }
 }
 try {
 mdl.setValue(mdl.getNextValue());
 this.jtxtCarCount.setText("");
 this.jtxtCarCount.setFocusable(true);
 } catch (Exception e) {
 }
 if (b)
 this.jbtnOK.setEnabled(true);
 }// GEN-LAST:event_jButton1ActionPerformed

 private void jbtnStopCountActionPerformed(ActionEvent evt) {// GEN-FIRST:event_jbtnStopCountActionPerformed
// TODO 将在此处添加您的处理代码:
  String s = this.jtxtStopCount.getText();
 int i = Integer.parseInt(s);
 m_Area = new int[i];
 for (i = 0; i < m_Area.length; i++) {
 this.m_Area[i] = -1;// Integer.parseInt
 }
 this.jSpinnerStopArea.setEnabled(true);
 this.jtxtCarCount.setEnabled(true);
 mdl.setMinimum(new Integer(1));
 mdl.setMaximum(new Integer(m_Area.length));
 mdl.setValue(new Integer(1));
 }// GEN-LAST:event_jbtnStopCountActionPerformed

 /**
  * @param args the command line arguments
  */

 public static void main(String args[]) {
  java.awt.EventQueue.invokeLater(new Runnable() {
   public void run() {
    new InitFrame().setVisible(true);
   }
  });
 }

/*
 public void setValue(WorkFram frm) {
  frm.m_areaCount = this.m_Area.length;
  frm.m_apare = new int[frm.m_areaCount];
  frm.m_nos = new int[frm.m_areaCount];
  for(int i = 0; i < frm.m_areaCount; i++){
   frm.m_apare[i] = this.m_Area[i];
   frm.m_nos[i] = this.m_Area[i];
  }
 }
*/

}

carThread.java

package com.parking;

/*
 * carThread.java
 *
 * Created on 2008年9月2日, 下午9:02
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

/**
 *
 * @author cheng
 */
public class carThread extends Thread {

 private WorkFram frm;

 /** Creates a new instance of carThread */
 public carThread(WorkFram frm) {
 this.frm = frm;
 }

 public void run() {
 new carJFrame(frm).setVisible(true);
 }

}

carJFrame.java

package com.parking;

/*
 * carJFrame.java
 *
 * Created on 2008年9月2日, 下午9:01
 */

/**
 *
 * @author cheng
 */

import javax.swing.*;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class carJFrame extends JFrame {

 /**
 *
 */
 private static final long serialVersionUID = 1L;

 /**
  * @param args the command line arguments
  */

 // 变量声明 - 不进行修改//GEN-BEGIN:variables

 private JButton jbtnEnterStop;

 private JButton jbtnLeftArea;

 private JButton jbtnLeftStop;

 private JButton jbtnLookUpArea;

 private JButton jbtnLookupPosition;

 private WorkFram mainFram;

 private int chooseArea;

 // 变量声明结束//GEN-END:variables

 /** Creates new form carJFrame */

 public carJFrame(WorkFram frm) {
  initComponents();
  mainFram = frm;
 }

 /**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() {

  jbtnEnterStop = new JButton();
  jbtnLookUpArea = new JButton();
  jbtnLookupPosition = new JButton();
  jbtnLeftArea = new JButton();
  jbtnLeftStop = new JButton();

  setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

  setTitle("\u505c\u8f66\u573a\u64cd\u4f5c");

  jbtnEnterStop.setText("\u8fdb\u5165\u505c\u8f66\u573a");

  jbtnEnterStop.addActionListener(new ActionListener() {
   public void actionPerformed(ActionEvent evt) {
    jbtnEnterStopActionPerformed(evt);
   }
  });

  jbtnLookUpArea.setText("\u5bfb\u627e\u505c\u8f66\u533a");

  jbtnLookUpArea.addActionListener(new ActionListener() {
   public void actionPerformed(ActionEvent evt) {
    jbtnLookUpAreaActionPerformed(evt);
   }
  });

  jbtnLookupPosition.setText("\u5bfb\u627e\u505c\u8f66\u4f4d");

  jbtnLookupPosition.addActionListener(new ActionListener() {
   public void actionPerformed(ActionEvent evt) {
    jbtnLookupPositionActionPerformed(evt);
   }
  });

  jbtnLeftArea.setText("\u79bb\u5f00\u505c\u8f66\u533a");

  jbtnLeftArea.addActionListener(new ActionListener() {
   public void actionPerformed(ActionEvent evt) {
    jbtnLeftAreaActionPerformed(evt);
   }
  });

  jbtnLeftStop.setText("\u79bb\u5f00\u505c\u8f66\u573a");

  jbtnLeftStop.addActionListener(new ActionListener() {
   public void actionPerformed(ActionEvent evt) {
    jbtnLeftStopActionPerformed(evt);
   }
  });

  jbtnEnterStop.setEnabled(true);
  jbtnLookUpArea.setEnabled(false);
  jbtnLookupPosition.setEnabled(false);
  jbtnLeftArea.setEnabled(false);
  jbtnLeftStop.setEnabled(false);

  addWindowListener(new WindowAdapter() {
   public void windowClosing(WindowEvent evt) {
    formWindowClosing(evt);
   }
  });

  GroupLayout layout = new GroupLayout(getContentPane());

  getContentPane().setLayout(layout);

  layout.setHorizontalGroup(
   layout.createParallelGroup(GroupLayout.Alignment.LEADING)
   .addGroup(layout.createSequentialGroup()
    .addGap(102, 102, 102)
    .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
     .addComponent(jbtnLeftStop)
     .addComponent(jbtnLeftArea)
     .addComponent(jbtnLookupPosition)
     .addComponent(jbtnLookUpArea)
     .addComponent(jbtnEnterStop))
    .addContainerGap(205, Short.MAX_VALUE))
  );

  layout.setVerticalGroup(
   layout.createParallelGroup(GroupLayout.Alignment.LEADING)
   .addGroup(layout.createSequentialGroup()
    .addGap(56, 56, 56)
    .addComponent(jbtnEnterStop)
    .addGap(20, 20, 20)
    .addComponent(jbtnLookUpArea)
    .addGap(22, 22, 22)
    .addComponent(jbtnLookupPosition)
    .addGap(24, 24, 24)
    .addComponent(jbtnLeftArea)
    .addGap(19, 19, 19)
    .addComponent(jbtnLeftStop)
    .addContainerGap(44, Short.MAX_VALUE))
  );

  pack();

 }// </editor-fold>//GEN-END:initComponents

 private void jbtnLeftStopActionPerformed(ActionEvent evt) {//GEN-FIRST:event_jbtnLeftStopActionPerformed
// TODO 将在此处添加您的处理代码:
  //离开停车场,交存车卡

  JOptionPane.showMessageDialog(null, "停车卡收回,再见!");
/*  jbtnEnterStop.setEnabled(true);
  jbtnLookUpArea.setEnabled(false);
  jbtnLookupPosition.setEnabled(false);
  jbtnLeftArea.setEnabled(false);
  jbtnLeftStop.setEnabled(false);
*/
  this.setVisible(false);
 this.removeNotify();

 }//GEN-LAST:event_jbtnLeftStopActionPerformed

 private void jbtnLeftAreaActionPerformed(ActionEvent evt) {//GEN-FIRST:event_jbtnLeftAreaActionPerformed
// TODO 将在此处添加您的处理代码:
  //离开停车区

  int confirm = JOptionPane.showConfirmDialog(null, "确定要离开 " + chooseArea + " 号停车区?", "离开停车区", JOptionPane.YES_NO_OPTION);
 if (confirm == JOptionPane.YES_OPTION) {
 mainFram.m_apare[chooseArea - 1]++;
// mainFram.setInfor(mainFram.getStopStatus());
 jbtnLeftArea.setEnabled(false);
 jbtnLookUpArea.setEnabled(true);
 jbtnLeftStop.setEnabled(true);
 } else if (confirm == JOptionPane.NO_OPTION) {
 JOptionPane.showMessageDialog(null, "您已放弃了离开该车区!");
 jbtnLookUpArea.setEnabled(true);
 } 

 }//GEN-LAST:event_jbtnLeftAreaActionPerformed

 private void jbtnLookupPositionActionPerformed(ActionEvent evt) {//GEN-FIRST:event_jbtnLookupPositionActionPerformed
// TODO 将在此处添加您的处理代码:
  //进入停车区,寻找停车位

  int confirm = JOptionPane.showConfirmDialog(null, "您已经选择了" + chooseArea + " 号停车区, " + "确定要进入该停车区?", "进行停车区寻找车位", JOptionPane.YES_NO_OPTION);
 if (confirm == JOptionPane.YES_OPTION) {
 mainFram.m_apare[chooseArea - 1]--;
// mainFram.setInfor(mainFram.getStopStatus());
 jbtnLookUpArea.setEnabled(false);
 jbtnLookupPosition.setEnabled(false);
 jbtnLeftArea.setEnabled(true);
 jbtnLeftStop.setEnabled(false);
 } else if (confirm == JOptionPane.NO_OPTION) {
 JOptionPane.showMessageDialog(null, "您已放弃了进入该车区!");
 jbtnLookUpArea.setEnabled(true);
 jbtnLookupPosition.setEnabled(false);
 } 

 }//GEN-LAST:event_jbtnLookupPositionActionPerformed

 private void jbtnLookUpAreaActionPerformed(ActionEvent evt) {//GEN-FIRST:event_jbtnLookUpAreaActionPerformed
// TODO 将在此处添加您的处理代码:
  //进入停车场,寻找停车区

  ImageIcon icon = new ImageIcon("test.gif");
 int[] freeArea = getFreeArea();
 Object[] freeAreas = new Object[freeArea.length];
 for (int i = 0; i < freeArea.length; i++) {
 freeAreas[i] = freeArea[i];
 }

 Integer choose = (Integer)JOptionPane.showInputDialog(null, "当前停车场状况: \n" + mainFram.getStopStatus() + "\n请选择一个空闲车区:", "当前可先空闲车区: ", JOptionPane.PLAIN_MESSAGE, icon, freeAreas, (Integer)freeAreas[0]);

 if (choose != null) {
 JOptionPane.showMessageDialog(null, "您选择了进入" + choose.intValue() + "车区");
 chooseArea = choose.intValue();
 jbtnLookUpArea.setEnabled(false);
 jbtnLookupPosition.setEnabled(true);
 } else {
 JOptionPane.showMessageDialog(null, "您没有选择车区!");
 } 

 }//GEN-LAST:event_jbtnLookUpAreaActionPerformed

 private void jbtnEnterStopActionPerformed(ActionEvent evt) {//GEN-FIRST:event_jbtnEnterStopActionPerformed
// TODO 将在此处添加您的处理代码:
  //领卡,进入停车场

  boolean isFull = true;
  for (int i = 0; i < mainFram.m_areaCount; i++) {
  if (mainFram.m_apare[i] > 0) {
  isFull = false;
  }
  }

  if (isFull) {
  JOptionPane.showMessageDialog(null, "当前车场无空闲车区,请稍后再试!");
  } else {
  jbtnEnterStop.setEnabled(false);
   jbtnLookUpArea.setEnabled(true);
   jbtnLookupPosition.setEnabled(false);
   jbtnLeftArea.setEnabled(false);
   jbtnLeftStop.setEnabled(false);
   JOptionPane.showMessageDialog(null, "成功领取停车卡,请进去车场寻找停车区位!");
  }

 }//GEN-LAST:event_jbtnEnterStopActionPerformed

 private void formWindowClosing(WindowEvent evt) {// GEN-FIRST:event_formWindowClosing
  // TODO 将在此处添加您的处理代码:
  int confirm = JOptionPane.showConfirmDialog(null, "确定退出?", "退出停车区", JOptionPane.YES_NO_OPTION);
 if (confirm == JOptionPane.YES_OPTION) {
 if (chooseArea > 0) {
 mainFram.m_apare[chooseArea - 1]--;
 }
 this.setVisible(false);
 this.removeNotify();
 } else {
 this.setVisible(true);
 }
 }// GEN-LAST:event_formWindowClosing

 public int[] getFreeArea() {
  int count = 0;
  for (int i = 0; i < mainFram.m_areaCount; i++) {
  if (mainFram.m_apare[i] > 0) {
  count++;
  }
  }

  int[] freeArea = new int[count];

  for (int i = 0, j = 0; i < mainFram.m_areaCount; i++) {
  if (mainFram.m_apare[i] > 0) {
  freeArea[j++] = i + 1;
  }
  }

  return freeArea;
 }

}

源码下载:java停车场管理系统

更多学习资料请关注专题《管理系统开发》。

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持我们。

(0)

相关推荐

  • 简单实现Java版学生管理系统

    本文实例为大家分享了Java实现学生管理系统的具体代码,供大家参考,具体内容如下 package BookDemo_1; import javax.swing.*; import java.awt.*; import java.awt.event.*; public class Test { public static void main(String[] args) { StudentSys stuSys=new StudentSys("学生管理系统"); stuSys.initWi

  • Java GUI实现学生成绩管理系统

    学习java有一年多了,一直在做web方面的练习,在一个项目中发现需要用到GUI的相关知识,结果没法做出来,网上这方面的文章又不是很多,所有只好自己硬着头皮从头再学一遍了,不过学习后发现,其实GUI是非常有趣的,他并不像WEB程序一样依赖互联网,而且还有许多布局和android相差不是很大,这才发现自己竟又爱上GUI的开发了,不多说了,直接上代码吧,相信有过android或相关界面开发的都明白这其中的道理. 先看看效果吧 1.登录主界面 package edu.gzu.stuManager; i

  • javaWeb实现学生信息管理系统

    本文为大家分享了javaWeb实现学生信息管理系统,供大家参考,具体内容如下 初始版 初始版是没有加分页的.因为没怎么学过前端,界面很丑陋.主要技术:JSP,JavaBean,servlet,JDBC主要页面如下: 登录页面 主页 添加学生 查看所有学生 查询学生 工程目录 数据库 两个表,user表和student表.为了使用DBUtils工具,一定要注意数据库表的属性的命名和JavaBean的get(),set() 方法的匹配.比如t_user表里的uname,在JavaBean中是:pri

  • 图书管理系统java代码实现

    本文实例为大家分享了java实现图书管理系统的具体代码,供大家参考,具体内容如下 /* (程序头部注释开始) * 程序的版权和版本声明部分 * Copyright (c) 2011, 烟台大学计算机学院学生 * All rights reserved. * 文件名称:    <图书管理系统--java>                          * 作    者:       刘江波                       * 完成日期:    2012     年  3    

  • 一个简陋的java图书管理系统

    本文代码为原创一个简陋的管理系统,只做功能的测试.并没有去完善所有应有的功能,只做了输入输出查找,仅供参考! 菜单部分: import java.util.Scanner; public class Menu { int Min = 1; int Max = 3; public void getMenu(){ System.out.println("1.显示/2.输入/3.查找"); } public void getFindMenu(){ System.out.println(&qu

  • java学生管理系统界面简单实现(全)

    学生管理系统简单的实现,供初学Java Swing同学学习使用. import java.awt.Dimension; import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import jav

  • Java+MySQL实现学生信息管理系统源码

    基于Java swing+MySQL实现学生信息管理系统:主要实现JDBC对学生信息进行增删改查,应付一般课设足矣,分享给大家.(由于篇幅原因,代码未全部列出,如有需要留下邮箱) 鉴于太多同学要源码,实在发不过来,上传到github上 https://github.com/ZhuangM/student.git 1. 开发环境:jdk7+MySQL5+win7 代码结构:model-dao-view 2. 数据库设计--建库建表语句: CREATE DATABASE student; DROP

  • 图书管理系统java版

    本文的目的就是通过图书管理系统掌握数据库编程技术,能正确连接数据库,能对数据库中信息进行查询.插入.删除.修改. 内容:在数据库中创建一张书目信息表,包括书名.作者.出版社.出版日期.书号.价格字段.设计一个GUI界面进行书目管理.在该界面上有四个选项卡,分别是查询.插入.删除.修改.点击查询选项卡,出现的界面上有书名.作者.出版社.书号四个文本框,一个按钮和一个只读文本区.文本框内容可以为空,输入相应的查询信息后(例如根据书名查询可以仅输入书名),点击界面上的"查询"按钮,可以在界面

  • Java+Mysql学生管理系统源码

    最近正在学java和数据库,想起以前写的学生管理系统,都是从网上下载,敷衍了事.闲来无事,也就自己写了一个,不过功能实现的不是很多. 开发语言:java: 开发环境:Mysql, java: 开发工具:eclipse 开发此案例,首先得在电脑上有java开发环境和Mysql, java开发环境与Mysql的搭建,就不再叙述了,如果需要,请联系我最下面的联系方式:dingyelf@aliyun.com 此次系统比较简易:数据库中只有一个表:stu;功能:能够对学生增加.删除.修改. 开发步骤:  

  • java学生信息管理系统源代码

    本文实例为大家分享了java学生信息管理系统的具体代码,实现学生信息: 增加 int[] a=new int[9] .删除 .查找.更改,供大家参考,具体内容如下 /*学生信息管理系统,实现学生信息: *增加 int[] a=new int[9] *删除 *查找 *更改 */ import java.util.Scanner;//导入java输入流 import java.lang.*; import java.io.*; class Student { private static Stude

随机推荐