Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize parking lot Management system with java

Shulou Source: shulou.com Published: 2022-06-03 16:27:27 09月30日 Update

This article mainly introduces "how to realize the parking lot management system by java". In the daily operation, I believe that many people have doubts about how to realize the parking lot management system by java. The editor has consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to realize the parking lot management system by java". Next, please follow the editor to study!

The code is as follows:

WorkFram.javapackage com.parking;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.*;/* * WotkFram.java * * Created on, 7:57 * / / * * @ author cheng * / public class WorkFram extends JFrame {/ * * * / private static final long serialVersionUID = 1L / * * @ param args the command line arguments * / / variable declaration-do not modify / / GEN-BEGIN:variables private JButton jbtnEnter; private JButton jbtnRefrush; private JTextArea jtexInfor; public int m_apare count; / / number of parking spaces public int [] mpracticnos; / / number of parking spaces in each parking area public int [] m_apare / / number of free parking spaces per parking area / / end of variable declaration / / GEN-END:variables / / int InitFrame frm; / * * 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. */ // //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(); }// //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] >

< m_Area.length; i++) { if (m_Area[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_ this.removeNotify [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 [jacks +] = I + 1;}} return freeArea;}} at this point, the study on "how to implement the parking lot management system with java" is over, hoping to solve everyone's doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Tags: Code processing parking area parking variables free parking management system system management learning selection digits more condition parking help utility success next Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB vpn MySQL Linux Shulou Information