Oh, thanks Jos!
I did play around with it and ended up returning an int value and then using that value to determine the path to take, similiar to what you mentioned.
I will pluck away at the code next week, but I really do appreciate the input.. your code is much smoother than what I did!
User Profile
Collapse
-
ok, that worked, but not like I wanted, so before I post again guess I will try to look further. I did not want the following code to execute unless there were no exceptions..
[code=java]
recsel = Integer.parseIn t(searchStk.get Text());
searchStk.setTe xt("");
recsel = recsel - 1;
displayRec( recsel );
[/code]Leave a comment:
-
Fixed!!!!!!!!!
ok, got it.. had to dig deeep to find an example of how to add the code if there were no exceptions.....
Thanks!
[code=java]
private void searchButtonAct ionPerformed(ja va.awt.event.Ac tionEvent evt) {
function = "search";
try {
Integer.parseIn t( searchStk.getTe xt());
recsel = Integer.parseIn t(searchStk.get Text());
searchStk.setTe xt("");...Leave a comment:
-
Ok, quick update...
Doing this instead..
[code=java]
try {
getIntField();
} catch (ArrayIndexOutO fBoundsExceptio n e) {
message.setText ("Record not found");
} catch (NumberFormatEx ception e) {
message.setText ("Invalid Record, re-enter");
}
// recsel = Integer.parseIn t(searchStk.get Text());
// searchStk.setTe xt("");...Leave a comment:
-
Nope, that didn't work. Ok, maybe I missed the exit ramp on this one. Here are the two methods I had so far..
[code=java]
private void searchButtonAct ionPerformed(ja va.awt.event.Ac tionEvent evt) {
function = "search";
getIntField();
if (NumberFormatEx ception == "Invalid Number") {
message.setText ("Invalid!!! ");
}
else {
recsel = Integer.parseIn t(searchStk.get Text());...Leave a comment:
-
Ah, and then test if NumberFormatExc eption = x
[code=java]
if (NumberFormatEx ception = x) {
do this
}
else {
do that
}
[/code]
Something like that?Leave a comment:
-
Testing a method's return value after a call
I have tried to follow this and read around but I have a simple question..
I call method getIntField and return the value or exception, but I want to test that return.. If the value returned was not valid how to I trap and test that?
Method called...
[code=java]
public int getIntField() {
try {
return Integer.parseIn t( searchStk.getTe xt());
} catch (NumberFormatEx ception... -
Jos and everyone,
Thanks for the update. I didn't think it could be that simple to force it to do something like that. I appreciate the input a ton!Leave a comment:
-
Ok, as long as no one is going to give me grief about it. Is that a common shortcut or should I get used to doing it some other way?Leave a comment:
-
Int vs Text on setText for jbuttons
I have tried to search, maybe I did not locate the right information since I am new to these forums and new to java, but, I have a quick question...
I am working on an inventory program for a school homework assignment.. #5 to be exact, I am sure you guys are aware of them...
I have tried to find out exactly why this works this way but searching the web and other places I still can't put my finger on this simple question.....
No activity results to display
Show More
Leave a comment: