User Profile

Collapse

Profile Sidebar

Collapse
Noonga
Noonga
Last Activity: Dec 23 '08, 03:05 AM
Joined: Dec 18 '08
Location: Phoenix AZ
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • Noonga
    replied to Testing a method's return value after a call
    in Java
    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!
    See more | Go to post

    Leave a comment:


  • Noonga
    replied to Testing a method's return value after a call
    in Java
    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]
    See more | Go to post

    Leave a comment:


  • Noonga
    replied to Testing a method's return value after a call
    in Java
    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("");...
    See more | Go to post

    Leave a comment:


  • Noonga
    replied to Testing a method's return value after a call
    in Java
    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("");...
    See more | Go to post

    Leave a comment:


  • Noonga
    replied to Testing a method's return value after a call
    in Java
    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());...
    See more | Go to post

    Leave a comment:


  • Noonga
    replied to Testing a method's return value after a call
    in Java
    Ah, and then test if NumberFormatExc eption = x
    [code=java]

    if (NumberFormatEx ception = x) {
    do this
    }
    else {
    do that
    }
    [/code]

    Something like that?
    See more | Go to post

    Leave a comment:


  • Noonga
    started a topic Testing a method's return value after a call
    in Java

    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...
    See more | Go to post

  • Noonga
    replied to Int vs Text on setText for jbuttons
    in Java
    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!
    See more | Go to post

    Leave a comment:


  • Noonga
    replied to Int vs Text on setText for jbuttons
    in Java
    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?
    See more | Go to post

    Leave a comment:


  • Noonga
    started a topic Int vs Text on setText for jbuttons
    in Java

    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.....
    See more | Go to post
No activity results to display
Show More
Working...