Advertisement
Guest User

Untitled

a guest
Jan 18th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.81 KB | None | 0 0
  1. /*
  2.  Name: Nick Conklin
  3.  Course: CNT 4714 – Spring 2018
  4.  Assignment title: Program 1 – Event-driven Programming
  5.  Date: Sunday January 28, 2018
  6. */
  7.  
  8. package com.conklin;
  9.  
  10. import javax.swing.*;
  11. import java.awt.event.*;
  12. import java.io.*;
  13. import java.nio.file.Files;
  14. import java.nio.file.Path;
  15. import java.nio.file.Paths;
  16. import java.util.List;
  17. import java.util.ArrayList;
  18.  
  19. public class App extends JFrame {
  20.  
  21.     private JPanel pnlMain;
  22.     private JButton btnProcess;
  23.     private JButton btnConfirm;
  24.     private JButton btnViewOrder;
  25.     private JButton btnFinishOrder;
  26.     private JButton btnNewOrder;
  27.     private JButton btnExit;
  28.     private JTextField txtOrderQty;
  29.     private JTextField txtBookId;
  30.     private JTextField txtBookQty;
  31.     private JTextField txtItemInfo;
  32.     private JTextField txtSubtotal;
  33.     private JLabel lblOrderQty;
  34.     private JLabel lblBookId;
  35.     private JLabel lblBookQty;
  36.     private JLabel lblItemInfo;
  37.     private JLabel lblSubtotal;
  38.  
  39.     public App() {
  40.  
  41.         public static void updateLabelsAndButtons() {
  42.  
  43.         }
  44.  
  45.         // Action Listener for the Exit button
  46.         btnExit.addActionListener(e -> System.exit(0));
  47.  
  48.  
  49.         // Key Listener Event for the Order Qty Text Field
  50.         txtOrderQty.addKeyListener(new KeyAdapter() {
  51.             @Override
  52.             public void keyPressed(KeyEvent e) {
  53.                 // Get the string value of what was entered into the order qty text field
  54.                 String strOrderQty = txtOrderQty.getText();
  55.  
  56.                 // Convert it into an integer for use later
  57.                 int orderQty = 0;
  58.                 try {
  59.                     orderQty = Integer.parseInt(txtOrderQty.getText());
  60.                 } catch (NumberFormatException nfe) {
  61.                     JOptionPane.showMessageDialog(null, "Please input a number!");
  62.                 }
  63.             }
  64.         });
  65.  
  66.         btnProcess.addActionListener(new ActionListener() {
  67.             @Override
  68.             public void actionPerformed(ActionEvent e) {
  69.  
  70.             }
  71.         });
  72.  
  73.     }
  74.  
  75.     public static void main(String[] args) {
  76.         List<String> bookIDList = new ArrayList<String>();
  77.  
  78.         Path fileName = Paths.get("inventory.txt");
  79.  
  80.         try (InputStream in = Files.newInputStream(fileName);
  81.              BufferedReader reader = new BufferedReader(new InputStreamReader(in))) {
  82.             String line = null;
  83.             while ((line = reader.readLine()) != null) {
  84.                 System.out.println(line);
  85.             }
  86.         } catch (IOException x) {
  87.             System.err.println(x);
  88.         }
  89.  
  90.         JFrame frame = new JFrame("App");
  91.         frame.setContentPane(new App().pnlMain);
  92.         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  93.         frame.pack();
  94.         frame.setVisible(true);
  95.     }
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement