Results 1 to 3 of 3
  1. #1
    superhaNds is offline Senior Member
    Join Date
    Apr 2013
    Location
    Sweden
    Posts
    263
    Rep Power
    2

    Default Inexplicable Exception

    Hello, I am getting a totally inexplicable exception, when just yesterday it was working and nothing was altered.

    I have a gui that takes some info and I call a method that adds a Task object into a a List in a TimeFrame object
    I get an IllegalMonthInputException or an IllegalDayInputException or and IllegaPriorityException according to what data I input incorrectly. All these are checked exceptions and are thrown when the value is not valid
    How is this possible since I handle all of them inside the addTaskActions method. Also, the JOptionPane message I have inside the catch block is shown, but in the console I see the exception..


    the listener

    Java Code:
    btnAddTask.addActionListener(new ActionListener() {
    	    public void actionPerformed(ActionEvent e) {
    		int index = addTaskCombox.getSelectedIndex();
    		if (index != 0) {
    		    try {
    		        addTaskActions(taskOrganizer.getTimeFrames().get(index - 1));
    		        textField.setText(taskOrganizer.getTimeFrames().get(index - 1).getTitle());
    		        comboBox.setSelectedIndex(index);
    		    } catch (IndexOutOfBoundsException exce) {
    			JOptionPane.showMessageDialog(null, "No time frame in the selected slot");
    		    }
    		} else {
    		    JOptionPane.showMessageDialog(null, "No time frame selected");
    		}
    	    }
    	});
    and the method.

    Java Code:
    private void addTaskActions(TimeFrame t) {
    	if (!(estimatedhoursformatTF.getText().trim().length() == 0
    		|| hrsWrkdFormatTF.getText().trim().length() == 0
    		|| priorityFormatTF.getText().trim().length() == 0
    		|| titleFormatTF.getText().trim().length() == 0
    		|| startDateDayFormatTF.getText().trim().length() == 0
    		|| startDateMonthFormatTF.getText().trim().length() == 0
    		|| startDateYearFormatTF.getText().trim().length() == 0
    		|| dueDateDayFormatTF.getText().trim().length() == 0
    		|| dueDateMonthFormatTF.getText().trim().length() == 0
    		|| dueDateYearFormatTF.getText().trim().length() == 0)) {
    	    try {
    		t.addTask(new Task(
    			Integer.parseInt(estimatedhoursformatTF.getText()),
    			Integer.parseInt(hrsWrkdFormatTF.getText()),
    			Integer.parseInt(priorityFormatTF.getText()),
    			titleFormatTF.getText(),
    			categoryComboBox.getSelectedItem().toString(),
    			dtrpnDescriptionHere.getText(),
    			Integer.parseInt(startDateDayFormatTF.getText()),
    			Integer.parseInt(startDateMonthFormatTF.getText()),
    			Integer.parseInt(startDateYearFormatTF.getText()),
    			Integer.parseInt(dueDateDayFormatTF.getText()),
    			Integer.parseInt(dueDateMonthFormatTF.getText()),
    			Integer.parseInt(dueDateYearFormatTF.getText())));
    		JOptionPane.showMessageDialog(null, "Task Added",
    			"Message", JOptionPane.INFORMATION_MESSAGE);
    		setTableModel(new TableModelGUI(t.getTasks()));
    	    } catch (IllegalPriorityException | IllegalDayInputException | IllegalMonthInputException ex) {
    		JOptionPane.showMessageDialog(null, ex.getMessage(),"Error", JOptionPane.ERROR_MESSAGE);
    	    } catch (NumberFormatException ec) {
    		JOptionPane.showMessageDialog(null, "Hours require an integer number, not more than 9 digits",
    						"Error", JOptionPane.ERROR_MESSAGE);
    	    }
    	} else {
    	    JOptionPane.showMessageDialog(null, "Complete All Fields Please", "Fields Missing",
    		    				JOptionPane.INFORMATION_MESSAGE);
    	}
        }

  2. #2
    superhaNds is offline Senior Member
    Join Date
    Apr 2013
    Location
    Sweden
    Posts
    263
    Rep Power
    2

    Default Re: Inexplicable Exception

    OK, this is weird, after the time I spent on writing this.post, I run it again and now it works fine.. what the heck...

  3. #3
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Location
    Tucson, AZ
    Posts
    1,060
    Rep Power
    6

    Default Re: Inexplicable Exception

    Your guess is as good as mine. Those exceptions are not part of the standard API, so they must be coming from some library you're using.
    Get in the habit of using standard Java naming conventions!

Similar Threads

  1. unreported exception java.lang.Exception
    By Marisabel in forum New To Java
    Replies: 6
    Last Post: 05-01-2011, 03:21 AM
  2. Replies: 5
    Last Post: 02-14-2011, 11:39 PM
  3. Replies: 1
    Last Post: 02-06-2011, 05:38 AM
  4. Replies: 4
    Last Post: 10-25-2010, 07:42 PM
  5. Replies: 1
    Last Post: 03-08-2008, 06:41 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •