// SanaBanana import java.awt.*; import java.awt.event.*; import javax.swing.*; // all the multitudes of include files import java.text.DecimalFormat; import java.io.*; import java.io.File; import javax.swing.JFileChooser; public class check extends JFrame { private Container content; //fields private JPanel north, center, south; private JLabel label0, label1, label2, label3, label4; private ActionListener li1, li2; private Button button, increaser, decreaser; private JTextField[] inputs; private JLabel[][] labels; private int[] shipped; private int[] received; private static int z; private static check window; private String fileName; private String one="txt"; private boolean cancelled=true; private File f; private int todo=0; public check() //default-constructor { content = getContentPane(); content.setLayout(new BorderLayout()); north = new JPanel(); north.setLayout( new GridLayout(1, 1)); content.add(north, BorderLayout.NORTH); // create labels label0= createAndAddLabel("SKU", SwingConstants.CENTER, north); label1= createAndAddLabel("Description",SwingConstants.CENTER, north); label2= createAndAddLabel("Price",SwingConstants.CENTER, north); label3= createAndAddLabel("Sent",SwingConstants.CENTER, north); label4= createAndAddLabel("Received",SwingConstants.CENTER, north); // create center panel center = new JPanel(); center.setLayout( new GridLayout(z,5)); content.add(center, BorderLayout.CENTER); // create south panel south = new JPanel(); south.setLayout( new GridLayout (2, 1)); content.add(south, BorderLayout.SOUTH); JFileChooser fc= new JFileChooser(); //opens file box int x; String answer=""; x=fc.showOpenDialog(null); if(x == JFileChooser.APPROVE_OPTION) //if file opens { f= fc.getSelectedFile(); answer= f.getName(); todo=1; } //checks if txt file int dot= answer.indexOf('.'); String check= answer.substring(dot+1, answer.length()); if(!check.equalsIgnoreCase(one)) todo=0; if(todo==1) { try { BufferedReader in = new BufferedReader(new FileReader(f)); // file reader String line=in.readLine(); if(line.equalsIgnoreCase("completed - good")|| line.equalsIgnoreCase("completed - bad")) { JOptionPane.showMessageDialog(null, "Order already checked"); System.exit(0); } z=Integer.parseInt(line); System.out.println(z); inputs= new JTextField[z]; labels= new JLabel[z][4]; shipped= new int[z]; for(int q=0; q