![]() |
Why would you want to use user defined exception handling?In: Computers [Recategorize] |
[Edit] |
Answer
suppose u want to catch an exception which is not define by java. for example suppose u want that when use enter the value in password foeld if the value doesnot matches the user's actual password then it will generate an error.To catch this error u can create a subclass of throwable class and catch this.Whenever user try to enter the wrong password the exception is generated and the statements written in catch block is fired.
like this try { this.checkUser(); MainScreen screen = new MainScreen(); dispose(); } catch (InvalidUserException invl) { JOptionPane.showMessageDialog(this, "Invalid User or Password","FastSign Java", JOptionPane.ERROR_MESSAGE); psw_user.requestFocus(); psw_user.setText(""); }
Answer
suppose u want to catch an exception which is not define by java. for example suppose u want that when use enter the value in password foeld if the value doesnot matches the user's actual password then it will generate an error.To catch this error u can create a subclass of throwable class and catch this.Whenever user try to enter the wrong password the exception is generated and the statements written in catch block is fired.
like this try { this.checkUser(); MainScreen screen = new MainScreen(); dispose(); } catch (InvalidUserException invl) { JOptionPane.showMessageDialog(this, "Invalid User or Password","FastSign Java", JOptionPane.ERROR_MESSAGE); psw_user.requestFocus(); psw_user.setText(""); }
from
chandan Kumar(Soft.. Engineer in Animon Software Solutions,New Delhi)
(chandanparida@yahoo.co.in)
First answer by ID3537086609. Last edit by ID3537086609. Question popularity: 67 [recommend question]





