lundi 4 mai 2015

How do I make a retry pop up if the input isn't what is wanted?

So I am trying to make a JOptionPanel popup when a user doesn't put in a number from 0-60 in a JTextField, but I'm not sure how

Here is what I tried

else if(e.getSource() == Save) {

            Task task = new Task();
            task.hour = hin.getText();
            task.min = min.getText();
            if(min.getText() > 0 && min.getText() < 60) {
                JOptionPane.showMessageDialog(null, "Please enter a valid time.");
            }
            else{
            task.day = (String) dayspinner.getValue();
            task.description = desc.getText();
            tasks.add(task);
            ObjectOutputStream os = null;
            try{
                os = new ObjectOutputStream(new FileOutputStream(save));
                os.writeObject(tasks);
                os.close();
            }catch(IOException ex) {
                ex.printStackTrace();
            }
            tframe.setVisible(false);
            }
        }

But I get errors that say "bad operand types for binary operator'<'".

Aucun commentaire:

Enregistrer un commentaire