IMG-LOGO
×

Tài Liệu Học

Khoá học lập trình Java Core căn bản (OOP)

Hướng Dẫn Cài Đặt Môi Trường

[Video] - Hướng dẫn cài đặt môi trường [Video] - Hướng dẫn tạo dự án Hello World [Video] Hướng dẫn phát hành dự án java - Lập trình Java căn bản

Khai Báo Biến & Mệnh Đề Điều Kiện & Vòng Lặp

[Video] - Khai báo biến & Toán tử trong Java [Video] - Tìm hiểu về Scanner, mệnh đề điều kiền if, else, switch trong java [Video] Tìm hiểu Loop (for, while, do while) - Lập trình Java căn bản

Array

[Video] Tìm hiểu về mảng (array) và List, ArrayList trong Java - Lập trình Java căn bản [Video] Hướng dẫn Collections Java | List & ArrayList Java | Vector Java | Map & Hashmap Java | String Java [Video] Test - Tìm kiếm chuỗi trong chuỗi

OOP - Tích Chất Đóng Gói & Kế Thừa

[Video] Tìm hiểu về Class và Object trong lập trình Java - Lập trình Java căn bản [Video] OOP - Tích chất bao đóng - Kế thừa trong Java - Lập trình Java căn bản [Video] Kế thừa OOP - Lập trình java - Lập trình Java căn bản [Video] OOP - Tính Chất Đa Hình - Tính Chất Trừu Tượng - Lập Trình Java Căn Bản [Video] Chu vi + Diện tích hình tròn và hình chữ nhật - lập trình Java căn bản [Video] Chữa bài tập kế thừa hình tròn + hình chữ nhật - lập trình Java căn bản - Đề 2 [Video] Quản Lí Cán Bộ [Video] Chũa bài tập Employee & StudentMark & Product trong lập trình OOP- lập trình Java căn bản [Video] Quản lý bể bơi bằng Java - Swimming Pool in Java [Video] Quản lý phòng tập GYM - Java basic [Video] Hướng dẫn chữa bài tập quản lý sách - lập trình java [Video] Chữa bài tập quản lý sinh viên - lập trình hướng đối tượng java [Video] Java Basic- OOP - Tổng hợp - Quản lý sinh viên - giáo viên bằng java - Phần 2

OOP - Interface

[Video] Interface - OOP lập trình java - Lập trình Java căn bản [Video] Java Basic- OOP - Tổng hợp - Quản lý sở thú [Video] Java Basic- OOP - Interface - Quản lý mèo (cat) trong java [Video] TEST- Chương trình quản lý rạp chiếu film bằng java [Video] Java basic- Overview - viết chương trình điều khiển TIVI bằng java [Video] Java basic- Overview - Viết chương trình quản lý xe car bằng java [Video] Hướng dẫn cú pháp Lambda Java | Tạo anonymous class Java | Interface Java & Abstract Java [Video] Chuyển DateTime sang String Java|Chuyển String sang DateTime Java | Base64 Java|MD5 Java|Cipher Java [Video] Hướng dẫn tìm hiểu Singleton Design Pattern Java | Singleton Object Java | OOP Java cho người mới

Examination & Test

[Video] Java Basic- Overview - Tổng hợp bài tập ôn luyện java basic - Kiểm tra 60 phút [Video] Exam - Kiểm tra 60 phút lập trình OOP - Quản lý thiết bị máy tính - Lập trình OOP

Java Swing

[Video] Hướng dẫn học Java Swing | Ví du quản lý sinh viên Java | Java Swing cho người mới bắt đầu

Ôn Tập Tổng Quát Java Basic

[Video] Phần mềm quản lý trường học - giảng dạy [Video] Optimize (Tối ưu code) - Phần mềm quản lý trường học - giảng dạy [Video] Java Basic- Test 60 phút lập trình java căn bản - Phần mềm quản lý bệnh nhân COVID-19 (2020 - TOOANG) [Video] bài tập quản lý xe cộ + quản lý bãi đỗ xe - lập trình java [Video] Java Basic - Quản lý ATM - Quản lý tài khoản ngân hàng




Trang Chủ Java Basic Quản lý phòng tập GYM - Java Swing

Quản lý phòng tập GYM - Java Swing

by GokiSoft.com - 20:23 13/04/2020 4,477 Lượt Xem

Yêu cầu thiết kế phần mềm quản lý phòng tập GYM


Thực hiện quản lý các chức năng sau

- Quản lý dụng cụ : tên dụng cụ, trọng lượng, chiều dài, rộng, cao, trạng thái (mới, cũ), loại (mua hay mượn)

- Quản lý đồ uống : tên đồ uống, giá tiền

- Quản lý vé: Tên khách hàng, ngày mua, ngày hết hạn

- Tạo lớp DataMgr (singleton) quản lý danh sách dụng cụ, đồ uống, vé trong phòng tập GYM.


Yêu cầu:

- Tạo form nhập thông tin dụng cụ => Dữ liệu lưu trong DataMgr

- Tạo form nhập đồ uống => Dữ liệu lưu trong DataMgr

- Tạo form nhập vé => Dữ liệu lưu trong DataMgr


MainForm


Các form Dụng Cụ, Đồ Uống, Vé Tháng => Hiển thị nhập + quản lý danh sách từng loại trên Table.

MainForm hiển thị thống kê như hình trên.

Bình luận



Phản Hồi Bởi:

(1) Nguyễn Hoàng Anh [C1907L]

Chia sẻ từ lớp học

Nguyễn Hoàng Anh [C1907L]

Ngày viết: 08:54 15/04/2020



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package GYM;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Redmibook 14
 */
public class DataMgr {

    List<ToolManager> toolmanager;
    List<TicketManager> ticketmanager;
    List<DrinkManager> drinkmanager;

    public static DataMgr instance = null;

    public DataMgr() {
        toolmanager = new ArrayList<>();
        ticketmanager = new ArrayList<>();
        drinkmanager = new ArrayList<>();
    }
    
    public static synchronized DataMgr getInstance(){
        if(instance == null){
            instance = new DataMgr();
        }
        return instance;
    }

    public List<ToolManager> getToolmanager() {
        return toolmanager;
    }

    public List<TicketManager> getTicketmanager() {
        return ticketmanager;
    }

    public List<DrinkManager> getDrinkmanager() {
        return drinkmanager;
    }    

}



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package GYM;

/**
 *
 * @author Redmibook 14
 */
public class DrinkManager {
    String DrinkName;
    float DrinkPrice;

    public DrinkManager(String DrinkName, float DrinkPrice) {
        this.DrinkName = DrinkName;
        this.DrinkPrice = DrinkPrice;
    }

    public DrinkManager() {
    }

    public String getDrinkName() {
        return DrinkName;
    }

    public float getDrinkPrice() {
        return DrinkPrice;
    }

    public void setDrinkName(String DrinkName) {
        this.DrinkName = DrinkName;
    }

    public void setDrinkPrice(float DrinkPrice) {
        this.DrinkPrice = DrinkPrice;
    }
    
}



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package GYM;

/**
 *
 * @author Redmibook 14
 */
public class TicketManager {
    String CustomerName,ApplyDate,ExpiredDate;

    public TicketManager(String CustomerName, String ApplyDate, String ExpiredDate) {
        this.CustomerName = CustomerName;
        this.ApplyDate = ApplyDate;
        this.ExpiredDate = ExpiredDate;
    }

    public TicketManager() {
    }

    public String getCustomerName() {
        return CustomerName;
    }

    public String getApplyDate() {
        return ApplyDate;
    }

    public String getExpiredDate() {
        return ExpiredDate;
    }

    public void setCustomerName(String CustomerName) {
        this.CustomerName = CustomerName;
    }

    public void setApplyDate(String ApplyDate) {
        this.ApplyDate = ApplyDate;
    }

    public void setExpiredDate(String ExpiredDate) {
        this.ExpiredDate = ExpiredDate;
    }
    
}



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package GYM;

import java.util.Scanner;

/**
 *
 * @author Redmibook 14
 */
public class ToolManager {

    String ToolName,Status,Type;
    float Weight, Length, Width, Height;

    

    public ToolManager() {
    }

    public ToolManager(String ToolName, String Status, String Type, float Weight, float Length, float Width, float Height) {
        this.ToolName = ToolName;
        this.Status = Status;
        this.Type = Type;
        this.Weight = Weight;
        this.Length = Length;
        this.Width = Width;
        this.Height = Height;
    }

  

    public String getToolName() {
        return ToolName;
    }

    public float getWeight() {
        return Weight;
    }

    public float getLength() {
        return Length;
    }

    public float getWidth() {
        return Width;
    }

    public float getHeight() {
        return Height;
    }

    public void setToolName(String ToolName) {
        this.ToolName = ToolName;
    }

    public void setWeight(float Weight) {
        this.Weight = Weight;
    }

    public void setLength(float Length) {
        this.Length = Length;
    }

    public void setWidth(float Width) {
        this.Width = Width;
    }

    public void setHeight(float Height) {
        this.Height = Height;
    }

    

}



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package GYM;

import javax.swing.JFrame;
import javax.swing.JLabel;

/**
 *
 * @author Redmibook 14
 */
public class MainFrame extends javax.swing.JFrame {

    /**
     * Creates new form MainFrame
     */
    public MainFrame() {
        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.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        ToolAmount = new javax.swing.JLabel();
        DrinkAmount = new javax.swing.JLabel();
        TicketAmount = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenuItem3 = new javax.swing.JMenuItem();
        jMenuItem4 = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("GYM Manager");

        jLabel1.setText("Tổng số dụng cụ:");

        jLabel2.setText("Tổng loại đồ uống:");

        jLabel3.setText("Tổng vé tháng:");

        ToolAmount.setText("0");

        DrinkAmount.setText("0");

        TicketAmount.setText("0");

        jMenu1.setText("Quản Lý");

        jMenuItem1.setText("Dụng Cụ     ^ + 1");
        jMenuItem1.setContentAreaFilled(false);
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem1);

        jMenuItem3.setText("Đồ Uống    ^ + 2");
        jMenuItem3.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem3ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem3);

        jMenuItem4.setText("Vé Tháng    ^ + 3");
        jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem4ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem4);

        jMenuBar1.add(jMenu1);

        jMenu2.setText("Thoát");
        jMenuBar1.add(jMenu2);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(96, 96, 96)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 113, Short.MAX_VALUE)
                    .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(TicketAmount, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(DrinkAmount, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(ToolAmount, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(244, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(58, 58, 58)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(ToolAmount)
                    .addComponent(jLabel1))
                .addGap(45, 45, 45)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(DrinkAmount))
                .addGap(47, 47, 47)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(TicketAmount))
                .addContainerGap(118, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>                        

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {                                           
        // TODO add your handling code here:

        ToolManagerFrame frame = new ToolManagerFrame();
        frame.show();
    }                                          

    private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {                                           
        // TODO add your handling code here:
        DrinkManagerFrame d = new DrinkManagerFrame();
        d.show();
    }                                          

    private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {                                           
        // TODO add your handling code here:
        TicketManagerFrame t =  new TicketManagerFrame();
        t.show();
    }                                          

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        System.out.println("Hello");

        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new MainFrame().setVisible(true);
            }

        });

    }
    // Variables declaration - do not modify                     
    public static javax.swing.JLabel DrinkAmount;
    public static javax.swing.JLabel TicketAmount;
    public static javax.swing.JLabel ToolAmount;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem3;
    private javax.swing.JMenuItem jMenuItem4;
    // End of variables declaration                   

}



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package GYM;

import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author Redmibook 14
 */
public class DrinkManagerFrame extends javax.swing.JFrame {

    DefaultTableModel TableModel;

    /**
     * Creates new form DrinkManagerFrame
     */
    public DrinkManagerFrame() {
        initComponents();
        TableModel = (DefaultTableModel) tblDrink.getModel();
        showTable();
    }

    /**
     * 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.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        txtDrinkName = new javax.swing.JTextField();
        txtDrinkPrice = new javax.swing.JTextField();
        btnSave = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        tblDrink = new javax.swing.JTable();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("DrinkManager"));

        jLabel1.setText("Tên Đồ Uống :");

        jLabel2.setText("Giá Đồ Uống :");

        btnSave.setText("Save");
        btnSave.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSaveActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(24, 24, 24)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1)
                    .addComponent(jLabel2))
                .addGap(31, 31, 31)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txtDrinkPrice, javax.swing.GroupLayout.PREFERRED_SIZE, 201, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(txtDrinkName, javax.swing.GroupLayout.PREFERRED_SIZE, 201, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(33, 33, 33)
                        .addComponent(btnSave, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(23, 23, 23)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(txtDrinkName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnSave))
                .addGap(28, 28, 28)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(txtDrinkPrice, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(70, Short.MAX_VALUE))
        );

        tblDrink.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "No", "Tên Đồ Uống", "Giá Đồ Uống"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane1.setViewportView(tblDrink);
        if (tblDrink.getColumnModel().getColumnCount() > 0) {
            tblDrink.getColumnModel().getColumn(0).setResizable(false);
            tblDrink.getColumnModel().getColumn(1).setResizable(false);
            tblDrink.getColumnModel().getColumn(2).setResizable(false);
        }

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jScrollPane1))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(29, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>                        
    boolean isNumberic(String num) {
        if (num == null) {
            return false;
        }
        try {
            double d = Double.parseDouble(num);
            return true;
        } catch (NumberFormatException e) {
            return false;
        }
    }
    private void btnSaveActionPerformed(java.awt.event.ActionEvent evt) {                                        
        // TODO add your handling code here:
        String dName = txtDrinkName.getText();
        String dPrice = txtDrinkPrice.getText();
        if (isNumberic(dPrice) == false) {
            JOptionPane.showMessageDialog(this, "Drink price must be a numberic!");
            return;
        }
        DrinkManager drinkmanager = new DrinkManager(dName, Float.parseFloat(dPrice));
        DataMgr.getInstance().getDrinkmanager().add(drinkmanager);
        TableModel.addRow(new Object[]{TableModel.getRowCount() + 1, dName, dPrice});
        MainFrame.DrinkAmount.setText(""+DataMgr.getInstance().getDrinkmanager().size());
    }                                       
    void showTable() {
        for (int i = 0; i < DataMgr.getInstance().getDrinkmanager().size(); i++) {
            TableModel.addRow(new Object[]{TableModel.getRowCount() + 1,
                DataMgr.getInstance().getDrinkmanager().get(i).DrinkName,
                DataMgr.getInstance().getDrinkmanager().get(i).DrinkPrice});
        }

    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(DrinkManagerFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(DrinkManagerFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(DrinkManagerFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(DrinkManagerFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new DrinkManagerFrame().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify                     
    private javax.swing.JButton btnSave;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable tblDrink;
    private javax.swing.JTextField txtDrinkName;
    private javax.swing.JTextField txtDrinkPrice;
    // End of variables declaration                   
}



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package GYM;

import javax.swing.table.DefaultTableModel;

/**
 *
 * @author Redmibook 14
 */
public class TicketManagerFrame extends javax.swing.JFrame {
    DefaultTableModel TableModel;
    /**
     * Creates new form TicketManagerFrame
     */
    public TicketManagerFrame() {
        initComponents();
        TableModel = (DefaultTableModel) tblTicket.getModel();
        showTable();
    }

    /**
     * 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.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        txtCustomerName = new javax.swing.JTextField();
        txtApplyDate = new javax.swing.JTextField();
        txtExpriedDate = new javax.swing.JTextField();
        btnSave = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        tblTicket = new javax.swing.JTable();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Ticket Manager"));

        jLabel1.setText("Tên Khách Hàng :");

        jLabel2.setText("Ngày Đăng Ký :");

        jLabel3.setText("Ngày Hết Hạn : ");

        btnSave.setText("Save");
        btnSave.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSaveActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1)
                    .addComponent(jLabel2)
                    .addComponent(jLabel3))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(txtCustomerName, javax.swing.GroupLayout.PREFERRED_SIZE, 197, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(43, 43, 43)
                        .addComponent(btnSave, javax.swing.GroupLayout.DEFAULT_SIZE, 91, Short.MAX_VALUE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtApplyDate, javax.swing.GroupLayout.PREFERRED_SIZE, 197, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtExpriedDate, javax.swing.GroupLayout.PREFERRED_SIZE, 197, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(27, 27, 27)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(txtCustomerName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnSave))
                .addGap(21, 21, 21)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(txtApplyDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(27, 27, 27)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(txtExpriedDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(66, Short.MAX_VALUE))
        );

        tblTicket.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "No", "Tên Khách Hàng", "Ngày Đăng Ký", "Ngày Hết Hạn"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane1.setViewportView(tblTicket);
        if (tblTicket.getColumnModel().getColumnCount() > 0) {
            tblTicket.getColumnModel().getColumn(0).setResizable(false);
            tblTicket.getColumnModel().getColumn(1).setResizable(false);
            tblTicket.getColumnModel().getColumn(2).setResizable(false);
            tblTicket.getColumnModel().getColumn(3).setResizable(false);
        }

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jScrollPane1))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 142, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>                        

    private void btnSaveActionPerformed(java.awt.event.ActionEvent evt) {                                        
        // TODO add your handling code here:
        String cName = txtCustomerName.getText();
        String aDate = txtApplyDate.getText();
        String eDate = txtExpriedDate.getText();
        TicketManager ticketm = new TicketManager(cName,aDate,eDate);
        DataMgr.getInstance().getTicketmanager().add(ticketm);
        TableModel.addRow(new Object[] {TableModel.getRowCount()+1,cName,aDate,eDate});
        MainFrame.TicketAmount.setText(""+DataMgr.getInstance().ticketmanager.size());
    }                                       
    public void showTable(){
        for(int i = 0; i < DataMgr.getInstance().ticketmanager.size();i++){
            TableModel.addRow(new Object[] {TableModel.getRowCount()+1,
                DataMgr.getInstance().ticketmanager.get(i).CustomerName,
                DataMgr.getInstance().ticketmanager.get(i).ApplyDate,
                DataMgr.getInstance().ticketmanager.get(i).ExpiredDate});
        }
    }
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(TicketManagerFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(TicketManagerFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(TicketManagerFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(TicketManagerFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new TicketManagerFrame().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify                     
    private javax.swing.JButton btnSave;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable tblTicket;
    private javax.swing.JTextField txtApplyDate;
    private javax.swing.JTextField txtCustomerName;
    private javax.swing.JTextField txtExpriedDate;
    // End of variables declaration                   
}



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package GYM;

import static GYM.MainFrame.ToolAmount;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author Redmibook 14
 */
public class ToolManagerFrame extends javax.swing.JFrame {

    DefaultTableModel tablemodel;

    /**
     * Creates new form ToolManagerFrame
     */
    public ToolManagerFrame() {

        initComponents();
        tablemodel = (DefaultTableModel) jTable1.getModel();
        if (tablemodel.getRowCount() == 0) {
            showTable();
        }
    }

    /**
     * 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.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        txtToolName = new javax.swing.JTextField();
        txtToolWeight = new javax.swing.JTextField();
        txtToolLength = new javax.swing.JTextField();
        txtToolWidth = new javax.swing.JTextField();
        txtToolHeight = new javax.swing.JTextField();
        StatusBox = new javax.swing.JComboBox<>();
        TypeBox = new javax.swing.JComboBox<>();
        btnSave = new javax.swing.JButton();
        btnReset = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Quản Lý Dụng Cụ"));

        jLabel1.setText("Tên Dụng Cụ :");

        jLabel2.setText("Trọng Lượng (Kg) :");

        jLabel3.setText("Chiều Dài (cm) :");

        jLabel4.setText("Chiều Rộng (cm) :");

        jLabel5.setText("Chiều Cao (cm) :");

        jLabel6.setText("Trạng Thái :");

        jLabel7.setText("Loại :");

        StatusBox.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "New", "Old" }));

        TypeBox.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Buy", "Borrow" }));

        btnSave.setText("Save");
        btnSave.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSaveActionPerformed(evt);
            }
        });

        btnReset.setText("Reset");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(25, 25, 25)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel3)
                    .addComponent(jLabel2)
                    .addComponent(jLabel4)
                    .addComponent(jLabel5)
                    .addComponent(jLabel6)
                    .addComponent(jLabel7)
                    .addComponent(jLabel1))
                .addGap(34, 34, 34)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txtToolWidth)
                    .addComponent(txtToolHeight)
                    .addComponent(txtToolWeight)
                    .addComponent(txtToolLength)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtToolName, javax.swing.GroupLayout.PREFERRED_SIZE, 381, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addComponent(TypeBox, javax.swing.GroupLayout.Alignment.LEADING, 0, 95, Short.MAX_VALUE)
                                .addComponent(StatusBox, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addGap(44, 44, 44)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(btnSave, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btnReset, javax.swing.GroupLayout.DEFAULT_SIZE, 106, Short.MAX_VALUE))
                .addGap(34, 34, 34))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(txtToolName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnSave))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(txtToolWeight, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnReset))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(txtToolLength, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(txtToolWidth, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(txtToolHeight, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(StatusBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(TypeBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(26, Short.MAX_VALUE))
        );

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "No", "Tên Dụng Cụ", "Trọng Lượng", "Chiều Dài", "Chiều Rộng", "Chiều Cao", "Trạng Thái", "Loại"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane1.setViewportView(jTable1);
        if (jTable1.getColumnModel().getColumnCount() > 0) {
            jTable1.getColumnModel().getColumn(0).setResizable(false);
            jTable1.getColumnModel().getColumn(1).setResizable(false);
            jTable1.getColumnModel().getColumn(2).setResizable(false);
            jTable1.getColumnModel().getColumn(3).setResizable(false);
            jTable1.getColumnModel().getColumn(4).setResizable(false);
            jTable1.getColumnModel().getColumn(5).setResizable(false);
            jTable1.getColumnModel().getColumn(6).setResizable(false);
            jTable1.getColumnModel().getColumn(7).setResizable(false);
        }

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 189, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>                        
    public static boolean isNumeric(String strNum) {
        if (strNum == null) {
            return false;
        }
        try {
            double d = Double.parseDouble(strNum);
        } catch (NumberFormatException nfe) {
            return false;
        }
        return true;
    }
    private void btnSaveActionPerformed(java.awt.event.ActionEvent evt) {                                        
        // TODO add your handling code here:
        String toolname = txtToolName.getText();
        String toolheight = txtToolHeight.getText();
        String toollenght = txtToolLength.getText();
        String toolwidth = txtToolWidth.getText();
        String toolweight = txtToolWeight.getText();
        String status = StatusBox.getSelectedItem().toString();
        String type = TypeBox.getSelectedItem().toString();
        if (txtToolName.getText().isEmpty()) {
            JOptionPane.showMessageDialog(null, "Tool name cant't be empty!");
            return;
        }
        if (isNumeric(toolweight) == false) {
            JOptionPane.showMessageDialog(null, "Weight must be a number!");
            return;
        }
        if (isNumeric(toollenght) == false) {
            JOptionPane.showMessageDialog(null, "Lenght must be a number!");
            return;
        }
        if (isNumeric(toolwidth) == false) {
            JOptionPane.showMessageDialog(null, "Width must be a number!");
            return;
        }
        if (isNumeric(toolheight) == false) {
            JOptionPane.showMessageDialog(null, "Height must be a number!");
            return;
        }

        ToolManager t = new ToolManager(toolname, status, type, Float.parseFloat(toolweight),
                Float.parseFloat(toollenght), Float.parseFloat(toolwidth),
                Float.parseFloat(toolheight));
        DataMgr.getInstance().getToolmanager().add(t);
        tablemodel.addRow(new Object[]{tablemodel.getRowCount() + 1, toolname,
            toolweight + "kg", toollenght + "cm", toolwidth + "cm", toolheight + "cm",
            status, type});
       
        MainFrame.ToolAmount.setText(""+DataMgr.getInstance().getToolmanager().size());

    }                                       
    private void showTable() {
        for (int i = 0; i < DataMgr.getInstance().getToolmanager().size(); i++) {
            tablemodel.addRow(new Object[]{tablemodel.getRowCount() + 1,
                DataMgr.getInstance().getToolmanager().get(i).ToolName,
                DataMgr.getInstance().getToolmanager().get(i).Weight + "kg",
                DataMgr.getInstance().getToolmanager().get(i).Length + "cm",
                DataMgr.getInstance().getToolmanager().get(i).Width + "cm",
                DataMgr.getInstance().getToolmanager().get(i).Height + "cm",
                DataMgr.getInstance().getToolmanager().get(i).Status,
                DataMgr.getInstance().getToolmanager().get(i).Type});
        }
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(ToolManagerFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(ToolManagerFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(ToolManagerFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(ToolManagerFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new ToolManagerFrame().setVisible(true);

            }

        });

    }

    // Variables declaration - do not modify                     
    private javax.swing.JComboBox<String> StatusBox;
    private javax.swing.JComboBox<String> TypeBox;
    private javax.swing.JButton btnReset;
    private javax.swing.JButton btnSave;
    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.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable jTable1;
    private javax.swing.JTextField txtToolHeight;
    private javax.swing.JTextField txtToolLength;
    private javax.swing.JTextField txtToolName;
    private javax.swing.JTextField txtToolWeight;
    private javax.swing.JTextField txtToolWidth;
    // End of variables declaration                   
}


Phân Loại Bài Viết

Tài Liệu Tham Khảo

Đã sao chép!!!