Hi all, I am trying to use a JFrame to open up extra windows that will prompt the user the Log In or Out, but I am getting an error with one of my variables that writes to Excel. If someone could help me out, that would be fantastic. There is something wrong with the variable "sheet" contained in the "while(i <= 4)"
private void createLabel(WritableSheet sheet) throws WriteException { WritableFont times10pt = new WritableFont(WritableFont.TIMES, 10); times = new WritableCellFormat(times10pt); times.setWrap(true); WritableFont times10ptBoldUnderline = new WritableFont(WritableFont.TIMES, 10, WritableFont.BOLD, false, UnderlineStyle.SINGLE); timesBoldUnderline = new WritableCellFormat(times10ptBoldUnderline); timesBoldUnderline.setWrap(true); CellView cv = new CellView(); cv.setFormat(times); cv.setFormat(timesBoldUnderline); cv.setAutosize(true); addCaption(sheet, 0, 0, "User"); addCaption(sheet, 1, 0, "ID Number"); addCaption(sheet, 2, 0, "Time Logged In"); JFrame frame = new JFrame(); frame.setLocationRelativeTo(null); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setFocusable(true); frame.setResizable(false); JButton button = new JButton("LogIn"); JButton button1 = new JButton("LogOut"); JButton button2 = new JButton("Exit"); ActionListener actionListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { for(int i = 1; i < 4; i++) { while(i <= 4) { Date now = Calendar.getInstance().getTime(); DateFormat customDateFormat = new DateFormat ("hh::mm::ss"); WritableCellFormat dateFormat = new WritableCellFormat (customDateFormat); String x = JOptionPane.showInputDialog(null, "User"); String y = JOptionPane.showInputDialog(null, "ID Number"); JOptionPane.showMessageDialog(null, "User " + x + " with ID Number " + y + " Logged In Successfully"); addCaption(sheet, 0, i, x); addCaption(sheet, 1, i, y); DateTime dateCell = new DateTime(2, i, now, dateFormat); sheet.addCell(dateCell); break; } } } }; button.addActionListener(actionListener); Container contentPane = frame.getContentPane(); contentPane.add(button, BorderLayout.WEST); contentPane.add(button1, BorderLayout.CENTER); contentPane.add(button2, BorderLayout.EAST); frame.setSize(300, 100); frame.setVisible(true);