Error CreateImage in for loop array

Hi,
I would like to dynamically create images inside a for loop. It dependent on the array_size that the sevlets will send. Snapshots of code:
for (int i = 0; i < ARRAY_SIZE; i++)
img[i] = Image.createImage("\"/nike" + (i+1) + ".png\"");
}Error:
java.io.IOException
     at javax.microedition.lcdui.ImmutableImage.getImageFromStream(+15)
     at javax.microedition.lcdui.ImmutableImage.<init>(+20)
     at javax.microedition.lcdui.Image.createImage(+8)
     at SlidesCanvas.createImages(+138)
     at SlidesCanvas.<init>(+146)
     at ListSlides.commandAction(+113)
     at javax.microedition.lcdui.Display$DisplayAccessor.commandAction(+282)
     at javax.microedition.lcdui.Display$DisplayManagerImpl.commandAction(+10)
     at com.sun.midp.lcdui.DefaultEventHandler.commandEvent(+68)
     at com.sun.midp.lcdui.AutomatedEventHandler.commandEvent(+47)
     at com.sun.midp.lcdui.DefaultEventHandler$QueuedEventHandler.run(+250)
Is this a known bug in CreateImage? Or am i doing it in a wrong way?

Herlena
I tried this, it works.
for (int i = 0; i < ARRAY_SIZE; i++) {
    img[i] = img.createImage("nike" + (i+1) + ".png");
Hope your problem is solved, Darryl

Similar Messages

  • Incompatible types error on a for loop

    Hi. I am in the middle of making a program and a decided to make a print statment to check to make sure everything was organized as it should be and I got an incompatible types error for the line where I start my for loop - for (index = 0 ...) etc. Since everything is an int, I'm not sure how they're not compatible with each other.. thoughts? here's my code so far, thanks
    import java.io.*; // needed for stream readers
    import java.lang.*;
    public class testScores extends Object
         public static void main(String args[] ) throws Exception
         // declare variables for input
    String      records;
    String      room_nbr_input;
    String      test_score_input;
    String      student_id;
    int          room_nbr_nbr;
    int          test_score_nbr;
    int          index;
    String[] record = new String[3];
    int[]     room_nbr = new int[30];
    int[]      test_score = new int[30];
    int[]     kount = new int[30];
         // created file reader and buffered reader
              FileReader frM;
              BufferedReader brM;
              // open file
              frM = new FileReader("einstein_testscores_2009.txt");
              brM = new BufferedReader(frM);
         // print headings
              startUp();
              // get one record from file
              records = brM.readLine();
              while(records !=null)
              //split the record into three fields = the array record[], then assign those values to variables
              record = records.split(", ");
              student_id = record[0];
              room_nbr_input = record[1];
              test_score_input = record[2];
              //change the data into integers
              room_nbr_nbr = Integer.parseInt(room_nbr_input);
              test_score_nbr = Integer.parseInt(test_score_input);
              //put the variables into arrays
              room_nbr[room_nbr_nbr -1] = room_nbr_nbr;
              test_score[room_nbr_nbr -1] = test_score[room_nbr_nbr -1] + test_score_nbr;
              //get new record
              records = brM.readLine();
              for (index = 0; index = room_nbr.length; index++)
                   System.out.print(room_nbr[index] + "\t\t" + test_score[index]);
         public static void startUp()
         System.out.print("Einstein Elementary Test Scores\n\n");
         System.out.print("Room Number\t\tTest Score Average\n\n");
    }          // end of class declaration

    thank you. here's the code.
    import java.io.*;       // needed for stream readers
    import java.lang.*;   
    public class testScores extends Object
         public static void main(String args[] ) throws Exception
         // declare variables for input
            String      records;
            String      room_nbr_input;
            String      test_score_input;
            String      student_id;
            int             room_nbr_nbr;
            int             test_score_nbr;
            int          index;
            String[] record = new String[3];
            int[]      room_nbr = new int[30];
            int[]       test_score = new int[30];
            int[]      kount = new int[30];
              // created file reader and buffered reader
              FileReader frM;
              BufferedReader brM;
              // open file
              frM = new FileReader("einstein_testscores_2009.txt");
              brM = new BufferedReader(frM);
         // print headings
              startUp();
              // get one record from file
              records = brM.readLine();
              while(records !=null)
              //split the record into three fields = the array record[], then assign those values to variables
              record = records.split(", ");
              student_id = record[0];
              room_nbr_input = record[1];
              test_score_input = record[2];
              //change the data into integers
              room_nbr_nbr = Integer.parseInt(room_nbr_input);
              test_score_nbr = Integer.parseInt(test_score_input);
              //put the variables into arrays
              room_nbr[room_nbr_nbr -1] = room_nbr_nbr;
              test_score[room_nbr_nbr -1] = test_score[room_nbr_nbr -1] + test_score_nbr;
              //get new record
              records = brM.readLine();
               for (index = 0; index = room_nbr.length; index++)
                    System.out.print(room_nbr[index] + "\t\t" + test_score[index]);
         public static void startUp()
         System.out.print("Einstein Elementary Test Scores\n\n");
         System.out.print("Room Number\t\tTest Score Average\n\n");
    }          // end of class declaration

  • Having errors in basic for loop

    Folks
    I am tring to write SQL script that implements a block that contains a for-loop which increments a counter from 1 to 10 and inserts the counter value into the results field of the LOOPING table that i have created. i want to insert a null val in place of the counter if the counter value is equal to either 6 or 8.
    Below are my work
    Table creation
    CREATE TABLE LOOPING (Result VARCHAR2(60));
    I am expecting a output like this
    Result
    1
    2
    3
    4
    5
    NULL
    7
    Null
    9
    10
    My SCRIPT
    BEGIN
    FOR COUNTER IN 1..10
    IF ((COUNTER = 6 ) AND (COUNTER = 8 ))
    THEN
    INSERT INTO MESSAGES
    VALUES(NULL);
    ELSE
    INSERT INTO MESSAGES
    VALUES(COUNTER);
    END LOOP;
    END;
    I am getting errors. I am a beginner . Please help me out .
    can you point out my errors and explain
    And finaly please tell me how to correct it .
    Thanks
    Guna

    1) When you get an error, it's always helpful to post the details of that error (the error number and the line number). That makes it far easier for us to help you.
    2) Thank you for posting your code and table definition. That definitely helps! In the future, you'll want to use the \ tag (6 characters, all lower case) before and after any code fragments to preserve the white space & indentation.  That makes your code far easier to read.
    3) Your code fails to compile because
    - you are missing the LOOP keyword between lines 2 and 3
    - you are missing the END IF at the end of your IF statement
    - you are referring to a table named MESSAGES while your CREATE TABLE statement refers to a table named LOOPING
    If you correct those three errors, your code will compile
    [code]
    SQL> ed
    Wrote file afiedt.buf
      1  BEGIN
      2    FOR COUNTER IN 1..10
      3    LOOP -- Added
      4      IF ((COUNTER = 6 ) AND (COUNTER = 8 ))
      5      THEN
      6        INSERT INTO looping -- Changed table name
      7          VALUES(NULL);
      8      ELSE
      9        INSERT INTO looping -- Changed table name
    10          VALUES(COUNTER);
    11      END IF; -- Added
    12    END LOOP;
    13* END;
    SQL> /
    PL/SQL procedure successfully completed.
    [/code]
    4) However, now that the code compiles, you'll have a problem that it does not meet the requirements.  It will never insert a NULL value because your IF condition is incorrect.  Since this looks like a homework problem, however, I don't want to completely give it away-- I've probably done more than I should have already.
    Justin                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • BUG: 10.1.3..36.73 Internal Compile Error with enhanced for loop/generics

    I get the following compiler error when using the Java 5 SE enhanced for loop with a generic collection.
    Code:
    public static void main(String[] args)
    List<Integer> l = new ArrayList<Integer>();
    l.add(new Integer(1));
    printCollection(l);
    private static void printCollection(Collection<?> c)
    for (Object e : c)
    System.out.println(e);
    Error on attempting to build:
    "Error: Internal compilation error, terminated with a fatal exception"
    And the following from ojcInternalError.log:
    java.lang.NullPointerException
         at oracle.ojc.compiler.EnhancedForStatement.resolveAndCheck(Statement.java:2204)
         at oracle.ojc.compiler.StatementList.resolveAndCheck(Statement.java:4476)
         at oracle.ojc.compiler.MethodSymbol.resolveMethod(Symbol.java:10822)
         at oracle.ojc.compiler.RawClassSymbol.resolveMethodBodies(Symbol.java:6648)
         at oracle.ojc.compiler.Parser.resolveMethodBodies(Parser.java:8316)
         at oracle.ojc.compiler.Parser.parse(Parser.java:7823)
         at oracle.ojc.compiler.Compiler.main_internal(Compiler.java:978)
         at oracle.ojc.compiler.Compiler.main(Compiler.java:745)
         at oracle.jdeveloper.compiler.Ojc.translate(Ojc.java:1486)
         at oracle.jdeveloper.compiler.UnifiedBuildSystem$CompileThread.buildGraph(UnifiedBuildSystem.java:300)
         at oracle.jdeveloper.compiler.UnifiedBuildSystem$CompileThread.buildProjectFiles(UnifiedBuildSystem.java:515)
         at oracle.jdeveloper.compiler.UnifiedBuildSystem$CompileThread.buildAll(UnifiedBuildSystem.java:715)
         at oracle.jdeveloper.compiler.UnifiedBuildSystem$CompileThread.run(UnifiedBuildSystem.java:893)

    Install the Service Update 1 patch for JDeveloper (using the help->check for updates), and let us know if this didn't solve the problem.

  • Illegal start of type error when adding for loop to applet

    I have typed the following applet to print a horizontal row of stars with the length entered by the user (i.e. user enters 4 and applet prints out 4 stars in a row). Here is my code:
    import java.awt.Graphics;
    import javax.swing.*;
    public class Histograms extends JApplet
           String input = "";
            int number;
         public void init()
              input = JOptionPane.showInputDialog ( null,
              "Enter a number\nbetween 1 and 30:" );
              number = Integer.parseInt( input );
         public void paint ( Graphics g )
              for ( int counter = 1; counter <= number; counter++ )
                                    System.out.print( "*" );
               System.out.println();
    };Now I am trying to make it do this 5 times, so it seems like just surrounding the init and paint methods in a for loop (i.e. for ( int i=1; i <= 5; i++ ) ) would do the trick but when I do that I get an illegal start of type error when trying to compile. Does anyone know why this error would show up. The most common reply to questions of this sort seems to be to check the closing braces but I have checked very carefully after adding the for loop and don't see any problems with mismatched braces. Could you please help me get on the right track as to how I can make this applet print a horizontal row of stars five times? All help is appreciated.

    Hello JTMOBOP:
    You were correct in figuring that I was trying to get the applet to print five rows of stars of different length according to five different inputs from the user. I tried your suggestions, and the code now does compile and run, but it still does not run properly (i.e. only asks user once for input and displays row of stars but does not show an input dialog again). Here is the code I have retyped:
    import java.awt.Graphics;
    import javax.swing.*;
    public class Histograms extends JApplet
       String input = "";
       int[] number = new int[5];
       public void init()
          for ( int i = 0; i < 5; i++ )
             input = JOptionPane.showInputDialog ( null,
                "Enter a number\nbetween 1 and 30:" );
             number[i] = Integer.parseInt( input );
       public void paint ( Graphics g )
          for ( int i = 0; i < 5; i++ )
             for ( int myNumber = 0; myNumber <= number; myNumber++ )
    System.out.print( "*" );
    System.out.println();
    Any ideas what's going on here?
    Also, your comments about not being able to loop a method make sense. Thank you for the input so far.

  • For loop array index not from 0

    HI!
    I have an array that is wired into a For Loop. Inside the For Loop there is already a single Array content available as there is this autoindexing feature (?). I do want to change the Array from a certain position different from 0 onwards to the end e.g. change positions 4, 5 and 6 in a for loop executing 3 times. But the for loop and the autoindexing feature start at 0. Can I change this in an elegant way. At the moment I'm running thru the hole array and begin changing at a certain position.

    Yes, disable autoindexing on the tunnel and use "index array" inside the loop. Use [n]+4 as index and wire a "3" to the loop count in your particular example.
    If you want to keep the entire array and just replace a few elements with updated values, the array needs to be fed in via a shift register. Write the new elements at the desired position using "replace array subset" (see attached very simple example).
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    ReplaceSomeArrayElements.gif ‏3 KB

  • Compile Error in Enhanced For Loop

    I'm learning generic collections and for practice wrote a simple class that uses a HashMap to store data. However, I'm getting a compile error for the code that accesses the HashMap. The error and code for my class follow.
    Can anyone help?
    Thanks...
    =====================
    The compile error:
    =====================
    MapDict.java:37: package Map does not exist for( Map.Entry entry : glossary.entrySet()  )                        ^1 error=======================
    The code for my class:
    =======================
    import java.util.Scanner;
    import java.util.HashMap;
    public class MapDict
         HashMap<String, String> glossary = new HashMap<String, String>();
         public void getEntries()
              Scanner sc = new Scanner( System.in ).useDelimiter("\n");
              String moreEntries = "y";
              String word        = "";
              String definition  = "";
              while ( moreEntries.toUpperCase().equals( "Y") )
                   System.out.print("Enter word: ");
                   word = sc.next();
                   System.out.print("Enter definition: ");
                   definition = sc.next();
                   glossary.put( word, definition);
                   System.out.print("Another glossary item? (y/n) ");
                   moreEntries = sc.next();
         public void displayEntries()
              System.out.println( glossary.size() );
              // Here is where the compile error occurs:
              for( Map.Entry entry : glossary.entrySet()  )
                   System.out.println( "\nWord: " + entry.getKey() + " Definition: " + entry.getValue() );
    }

    import java.util.Scanner;
    import java.util.HashMap;I don't see java.util.Map or java.util.Map.Entry listed here....

  • Error in cursor for loop

    Hi  Guys ,
    I am getting the below error in the following piece of code.I am using 11g.
           L_SQL_TXT:='begin'||CHR(32)||
          'for i in ( select '||l_col_list_1||', :in_tst_nm, :l_current_schema  from '||in_src_table||') LOOP
            insert into '||get_test_schema||'.'||in_src_table||' values('||l_col_list_2||',TEST_NM , TEST_CREATED_BY);
          end LOOP;
          end;';
          dbms_output.put_line (l_sql_txt);
          EXECUTE IMMEDIATE l_sql_txt USING in_sav_nm,l_current_schema;
          dbms_output.put_line (SQL%ROWCOUNT || ' test records added');
           I am getting the below error
    Error report:
    ORA-06550: line 3, column 95:
    PL/SQL: ORA-00984: column not allowed here
    ORA-06550: line 3, column 7:
    PL/SQL: SQL Statement ignored
    06550. 00000 -  "line %s, column %s:\n%s"
    *Cause:    Usually a PL/SQL compilation error.
    *Action:
    What am i doing wrong? Please suggest

    Raunaq wrote:
             insert into '||get_test_schema||'.'||in_src_table||' values('||l_col_list_2||',TEST_NM , TEST_CREATED_BY);
    This insert statement doesn't look good! As you just passed TEST_NM and TEST_CREATED_BY as in a string. Those must have some values associated with!
    Like:- If those 2 are variables then it should be like :-
    -- For testing purpose with output !!!
    --- Added static values for references for the dynamic block
    Declare
    l_sql_txt varchar2(32767);
    get_test_schema varchar2(20) := 'scott';
    in_src_table varchar2(20) := 'src_tbl';
    l_col_list_1 varchar2(20) := 'col_name_1';
    l_col_list_2 varchar2(20) := 'col_name_2';
    test_nm varchar2(20) := 'Testing';
    test_created_by date :=sysdate ;
    begin
      l_sql_txt:='begin'||chr(32)||
          'for i in ( select '||l_col_list_1||', :in_tst_nm, :l_current_schema  from '||in_src_table||')
       loop
            insert into '||get_test_schema||'.'||in_src_table||' values('||l_col_list_2||','''||test_nm||''','''||test_created_by||''');
          end loop;
          end;';
       dbms_output.put_line ('sql text- '||l_sql_txt);
       --execute immediate l_sql_txt using in_sav_nm,l_current_schema;
          dbms_output.put_line (sql%rowcount || ' test records added');
    end;
    My OutPut looks like:-
    sql text- begin for i in ( select col_name_1, :in_tst_nm, :l_current_schema
    from src_tbl)
              loop
            insert into scott.src_tbl
    values(col_name_2,'Testing','04-JUL-13');
          end loop;
          end;
    test records added
    PL/SQL procedure successfully completed.

  • How to handle error within a FOR loop

    Hi all,
    For the code:
    begin
        for vc1 in (select *
                      from xx_primavera_invoices_detail
                     where transfered_to_ar = 0
                       and cust_trx_type_id not in (1000, 1003, 1016, 1023, 1040)
                       and act_end_date is not null) loop
          insert_into_ar_interface(vc1.amount, vc1.uom_code, vc1.quantity, vc1.unit_standard_price, vc1.cust_trx_type_id
                                  ,vc1.description, vc1.interface_line_attribute1, vc1.interface_line_attribute2, vc1.interface_line_attribute3, vc1.service_code
                                  ,vc1.gl_date, vc1.orig_system_bill_address_id, vc1.orig_system_bill_customer_id, vc1.segment2, vc1.segment3,vc1.customer_name,vc1.payment_type,vc1.currency_code)
        end loop;
        update xx_primavera_invoices_detail
           set transfered_to_ar = 1
         where transfered_to_ar = 0
           and cust_trx_type_id not in (1000, 1003, 1016, 1023, 1040)
        end;I want to add an exception statement if there is no value returned in VC1. I guess i'll never go into the loop statement because no data found in VC1 but the UPDATE will be executed...
    Any ideas?
    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - Production
    PL/SQL Release 11.1.0.7.0 - Production
    "CORE     11.1.0.7.0     Production"
    TNS for Linux: Version 11.1.0.7.0 - Production
    NLSRTL Version 11.1.0.7.0 - ProductionThanks in advance,
    Bahchevanov.

    Hi,
    declare
      v_i_was_in_loop  boolean;
    begin
      v_i_was_in_loop ;= false;
      for cur in (select ..)
      loop
        null;
        v_i_was_in_loop := true;
      end loop; 
    if v_i_was_in_loop = true
    then
       update...
    end if;    
    end;

  • Compile error on .class for an array.

    How do I write the code below correctly?
            final ArgumentCaptor<MessageToken[]> tokenArg = ArgumentCaptor.forClass(MessageToken[].class);

    How do I write the code below correctly?
    final ArgumentCaptor<MessageToken[]> tokenArg = ArgumentCaptor.forClass(MessageToken[].class);
    What is the exact compilation error?
    Note that since ArgumentCaptor is probably a custom class that only you or your team knows about, we will maybe not be able to help a lot, we will probably need that you give us the signature of its method forClass
    Note that the problem is not that the syntaxfor the array class MessageToken[].class is illegal in itself; the following compiles perfectly:
    public class TestClassLitteral {
        Class stringClass = String.class;
        Class stringArrayClass = String[].class;
    }

  • Syntax error on a for loop

    I am getting an error on the first line of the for statement. It says I need a semicolon but I can't seem to correct it and I know the error might not necessarily be on that line. I'm not sure how this even is going to print at the end of the switch statement but i can't compile it to find out. I can show you in another post what i am trying to achieve if it will help. Thanks.
    import javax.swing.*;
    import java.text.*;
    public class printNum
    public static void main (String [] args) {
    String startNumStr, endNumStr;
    int startNum, endNum;
    startNumStr= JOptionPane.showInputDialog(null, "Enter a starting number:");
    startNum = Integer.parseInt(startNumStr);
    endNumStr = JOptionPane.showInputDialog(null, "Enter an ending number:");
    endNum = Integer.parseInt(endNumStr);
    for(int startNum < endNum) {
    switch(startNum) {
    case startNum + 10:
    case startNum + 10:
    case startNum + 10: System.out.println(" " + startNum); break;
    default: System.out.println(" " + startNum);
    }

    I am getting an error on the first line of the for
    statement. It says I need a semicolon but I can't
    seem to correct it and I know the error might not
    necessarily be on that line. I'm not sure how this
    even is going to print at the end of the switch
    statement but i can't compile it to find out. I can
    show you in another post what i am trying to achieve
    if it will help. Thanks.
    import javax.swing.*;
    import java.text.*;
    public class printNum
    public static void main (String [] args) {
    String startNumStr, endNumStr;
    int startNum, endNum;
    startNumStr=
    tNumStr= JOptionPane.showInputDialog(null, "Enter a
    starting number:");
    startNum = Integer.parseInt(startNumStr);
    endNumStr = JOptionPane.showInputDialog(null,
    og(null, "Enter an ending number:");
    endNum = Integer.parseInt(endNumStr);
    for(int startNum < endNum) {
    switch(startNum) {
    case startNum + 10:
    case startNum + 10:
    case startNum + 10:
    e startNum + 10: System.out.println(" " + startNum);
    break;
    default: System.out.println(" " +
    ut.println(" " + startNum);
    }Why do you have the same case 3 times in the switch? Also, I don't think you can have variable expressions in the switch statement cases. I think these need to be constants.
    RD-R
    � {�                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Problem cycling through elements of an array using a for loop ~ error 200609?

    Hi,
    I'm outputting a 194-element array from a MATLAB script node into a for loop where the array is indexed then converted into a 8-bit boolean pattern which I'm trying to output using DAQ Assistant. I'm using LabVIEW 8.2 and a PCI 6133 DAQ using a counter(Ctr0InternalOutput) to time the output. The first element of the array goes through the loop perfectly however never makes it's way back through and throws error 200609: Generation cannot be started because the slescted buffer size is too small. Increase the buffer size. After probing the line before DAQ Assistant I confirmed only one element makes it through the loop and then throws this error? I've trying doing the same things with lower lowel DAQmx vi's using a DAQmx configure output buffer vi to override this buffer size problem, but still get the same result(not the error but same data flow problem)? Anybody know what's going on? I've included the vi's I've been working with. Thanks!
    Millie
    Attachments:
    Untitled 22.vi ‏228 KB
    Untitled 34.vi ‏180 KB

    Hi,
    I'm outputting a 194-element array from a MATLAB script node into a for loop where the array is indexed then converted into a 8-bit boolean pattern which I'm trying to output using DAQ Assistant. I'm using LabVIEW 8.2 and a PCI 6133 DAQ using a counter(Ctr0InternalOutput) to time the output. The first element of the array goes through the loop perfectly however never makes it's way back through and throws error 200609: Generation cannot be started because the slescted buffer size is too small. Increase the buffer size. After probing the line before DAQ Assistant I confirmed only one element makes it through the loop and then throws this error? I've trying doing the same things with lower lowel DAQmx vi's using a DAQmx configure output buffer vi to override this buffer size problem, but still get the same result(not the error but same data flow problem)? Anybody know what's going on? I've included the vi's I've been working with. Thanks!
    Millie
    Attachments:
    Untitled 22.vi ‏228 KB
    Untitled 34.vi ‏180 KB

  • I need help with my for loop in this array

    Ok well, I can't get my code to work. Also, please remember that this is just my draft so it isnt pretty. I will fix it up later so please look at it. The thing I want to do is look into the array for a time that matches what the user entered and return the toString() of that one. I know there is something wrong with my for loop but I cant figure how to fix it. please help. here is what i have so far:
    import javax.swing.JOptionPane;
    public class Runner
        public static void main (String[] args)
            String timeStr;
            int time, again, optiStr;
            Inbound[] in = new Inbound[25];
             in[0]=new Inbound ("",0,"On Time num0");
             in[1]=new Inbound ("",2,"On Time num1");
             in[2]=new Inbound ("",3,"Delayed num2");
             in[3]=new Inbound ("",4,"On Time");
             in[4]=new Inbound ("",5,"On Time");
             in[5]=new Inbound ("",6,"Canceled");
             in[6]=new Inbound ("",1,"Canceled num6");
             in[7]=new Inbound ("",8,"On Time");
             in[8]=new Inbound ("",9,"Delayed");
             in[9]=new Inbound ("",10,"On Time");
             in[10]=new Inbound ("",11,"Delayed");
             in[11]=new Inbound ("",12,"On Time");
             in[12]=new Inbound ("",13,"Delayed");
             in[13]=new Inbound ("",14,"On Time");
             in[14]=new Inbound ("",15,"On Time");
             in[15]=new Inbound ("",16,"On Time");
             in[16]=new Inbound ("",17,"Canceled");
             in[17]=new Inbound ("",18,"On Time");
             in[18]=new Inbound ("",19,"On Time");
             in[19]=new Inbound ("",20,"Canceled");
             in[20]=new Inbound ("",21,"On Time");
             in[21]=new Inbound ("",22,"Delayed");
             in[22]=new Inbound ("",23,"On Time");
             in[23]=new Inbound ("",24,"Cancled");
             in[24]=new Inbound ("",7,"On Time num24");
            do{
                timeStr = JOptionPane.showInputDialog ("In military time, what hour do you want?");
                time = Integer.parseInt(timeStr);
                if (time<=0 || time>24)
                 JOptionPane.showMessageDialog (null, "Error");
                 optiStr = JOptionPane.showConfirmDialog (null, "If you want Incoming flights click Yes, but if not click No");
                if (optiStr==JOptionPane.YES_OPTION)
    //(ok this is the for loop i am talking about )
                    for (int index = 0; index < in.length; index++)
                      if ( time == Inbound.getTime())
                   JOptionPane.showMessageDialog (null, Inbound.tostring());  //return the time asked for
    //               else JOptionPane.showMessageDialog (null, "else");
                }//temp return else if failed to find time asked for
    //             else
    //               if (optiStr==JOptionPane.CANCEL_OPTION)
    //                 JOptionPane.showMessageDialog(null,"Canceled");
    //              else
    //                {Outbound.run();
    //                JOptionPane.showMessageDialog (null, "outbound");}//temp
                  again=JOptionPane.showConfirmDialog(null, "Try again?");
            while (again==JOptionPane.YES_OPTION);
    }any help would be greatly appriciated.

    rumble14 wrote:
    Ok well, I can't get my code to work. Also, please remember that this is just my draft so it isnt pretty. I will fix it up later so please look at it. The thing I want to do is look into the array for a time that matches what the user entered and return the toString() of that one. I know there is something wrong with my for loop but I cant figure how to fix it. please help. here is what i have so far:
    >//(ok this is the for loop i am talking about )
    for (int index = 0; index < in.length; index++)
    if ( time == Inbound.getTime())
    JOptionPane.showMessageDialog (null, Inbound.tostring());  //return the time asked for
    Inbound.getTime() is a static method of your Inbound class, that always returns the same value, I presume? As opposed to each of the 25 members of your array in, which have individual values?
    Edited by: darb on Mar 26, 2008 11:12 AM

  • Passing an array in a for loop to a procedure

    I am trying to pass an array in a cursor for loop to a procedure which performs a table insert using the array's contents. Somehow I am missing something, or it is not possible. The compile error states: PLS-00306: wrong number or types in call to 'insert_address' I checked to be sure I am creating the arrays in both cases from similar data objects. Both address and work_address_table contain the same 4 columns with the same data types.
    create or replace package work_address as
    FUNCTION populate_address return boolean;
    procedure insert_address(in_address IN work_address_table%ROWTYPE);
    end work_address;
    create or replace package body work_address as
    function populate_address return boolean is
    cursor c1 is
    select 'H' as header,
    street1 as street
    city as city,
    NULL as state
    from address
    where city = 'HANOVER';
    TYPE addressT IS TABLE OF c1%ROWTYPE INDEX BY BINARY_INTEGER;
    rec1 addressT;
    BEGIN
    OPEN c1;
    FETCH c1 BULK COLLECT INTO rec1 LIMIT 500;
    FOR i IN 1..rec1.count LOOP
    rec1(i).state := 'US'
    insert_address(rec1(i));
    exit when c1%notfound;
    END LOOP;
    CLOSE c1;
    return TRUE;
    END populate_address;
    PROCEDURE insert_address(in_address IN work_address_table%ROWTYPE) IS
    BEGIN
    INSERT INTO work_address_table
    VALUES (in_address.header,
    in_address.street,
    in_address.city,
    in_address.state);
    COMMIT;
    END insert_address;
    END work address;
    /

    Both address and work_address_table contain the same 4 columns with the same data types.Are you 100% sure about this?
    SQL> declare
      cursor c1
      is
        select 1 deptno, dummy dname, 'Loc' location from dual;
      type addresst is table of c1%rowtype
        index by binary_integer;
      rec1   addresst;
      procedure p (d dept%rowtype)
      as
      begin
        dbms_output.put_line(d.dname);
      end p;
    begin
      rec1 (1).dname := 'z';
      p (rec1 (1));
    end;
    z
    PL/SQL procedure successfully completed.but changing just the first column of the cursor:
    SQL> declare
      cursor c1
      is
        select 'xy' deptno, dummy dname, 'Loc' location from dual;
      type addresst is table of c1%rowtype
        index by binary_integer;
      rec1   addresst;
      procedure p (d dept%rowtype)
      as
      begin
        dbms_output.put_line(d.dname);
      end p;
    begin
      rec1 (1).dname := 'z';
      p (rec1 (1));
    end;
    Error at line 3
    ORA-06550: line 20, column 3:
    PLS-00306: wrong number or types of arguments in call to 'P'
    ORA-06550: line 20, column 3:
    PL/SQL: Statement ignored

  • For loop issue and error exception

    I am finishing up a program and having a few issues....I can send my instructions so it may seem easier to what I want...the first issue deals with the for loop for the 2nd for loop in the actionperformed when i click on go it does not change any of the boxes to yellow
    Also when I check for errors it does not check with the code I have...I know it says on the instructions to use try\catch but I am just going to use if statements because I am not very familar with the try\catch and will accept some points takin off...any help with this by tonight id really appreciate it as long as noone is too busy...Thanks
    instructions:
    This will incorporate arrays, for loops, and Frames all in one.
    Create a panel containing an array of 16 TextArea components that change color to correspond with the start, stop, and step values entered by the user. Perform the following tasks to create the Checkerboard Array application shown below. When the user enters the start, stop, and step fields and then clicks the Go button, the results are also shown below.
    1.     Call your application Checkerboard.java
    2.     You will need the following variables� declare them as private:
    a.     16 component TextArea array
    b.     a Panel to hold the array
    c.     3 TextField components with length of 10
    d.     3 int variables to receive the start, stop, and step values
    e.     3 Labels to display the words Start, Stop, and Step
    f.     a Go button
    g.     a Clear button
    h.     a Panel to hold the 3 TextFields, 3 Labels, and the 2 Buttons
    3.     Create a constructor method to:
    a.     construct each of the components declared above and initializes the start, stop, and step variables to zero (when constructing the TextArea components, use the following parameters: null, 3, 5, 3)
    b.     set the Frame layout to BorderLayout
    c.     write a for loop to loop the array and set each of the 16 TextArea components in that array so they cannot be edited. In the same loop, set each of the TextArea components text to be 1 more than the index number. Also in this same loop, set the background of each of the TextArea components to white.
    d.     set the Panel for the TextArea components to GridLayout with 4 rows, 4 columns, and both gaps set to 10
    e.     set the Panel for the TextFields, Labels, and button to GridLayout with 3 rows, 3 columns, and both gaps set to 5
    f.     add the components to their respective Panels
    g.     make the buttons clickable
    h.     place the Panels in the Frame� put one in the NORTH and one in the CENTER
    i.     Enter the addWindowListener() method described in the chapter� this is the method that overrides the click of the X so it terminates the application
    4.     In your actionPerformed() method:
    a.     convert the data in your TextFields to int and store them in the variables declared above
    b.     write a loop that goes through the array setting every background color to blue
    c.     write another loop that�s based on the user inputs. Each time the loop is executed, change the background color to yellow (so� start your loop at the user�s specified starting condition. You�ll stop at the user�s specified stopping value. You�ll change the fields to yellow every time you increment your loop based on the step value. REMEMBER: Your displayed values are 1 off from your index numbers!!)
    5.     Write a main() method that creates an instance of the Checkerboard Frame.
    a.     set the bounds for the frame to 50, 100, 300, 400
    b.     set the title bar caption to Checkerboard Array
    c.     use the setVisible() method to display the application Frame during execution
    6.     After you get all of this complete, include error handling to make sure:
    a.     the values entered in the TextFields are valid integers
    b.     the start value is greater than or equal to 1 and less than or equal to 16
    c.     the stop value is greater than or equal to 1 and less than or equal to 16
    d.     the step value is greater than or equal to 1 and less than or equal to 16
    e.     the start condition is less than the stop condition
    f.     when an error occurs, give an error message in a dialog box that is specific to their error, remove the text from the invalid field, and put the cursor in that field so the user has a chance to re-enter� this can be accomplished by using multiple try/catch statements
    g.     only change the colors if the numbers are valid
    7.     Create a clear button as seen in the example below. This button should:
    a.     clear out all 3 TextFields
    b.     change the background color of all TextArea array elements to white
    c.     put the cursor in the start field
    8.     Document!!
    my code is:
    //packages to import
    import javax.swing.JOptionPane;
    import java.awt.*;
    import java.awt.event.*;
    public class Checkerboard extends Frame implements ActionListener
         private Panel topPanel;
         private TextArea topDisplay[];
         private Panel bottomPanel;
         private TextField startField = new TextField(10);
         private TextField stopField = new TextField(10);
         private TextField stepField = new TextField(10);
         private Label startLabel = new Label ("Start");
         private Label stopLabel = new Label ("Stop");
         private Label stepLabel = new Label ("Step");
         private Button goButton;
         private Button clearButton;
         private boolean clearText;
         private boolean first;
         private int start;
         private int stop;
         private int step;
         //constructor methods
         public Checkerboard()
              //construct components and initialize beginning values
              topPanel = new Panel();
              topDisplay = new TextArea[16];
              goButton = new Button("Go");
              clearButton = new Button("Clear");
              first = true;
              bottomPanel = new Panel();
              int start = 0;
              int stop = 0;
              int step = 0;
              bottomPanel.add(startField);
              bottomPanel.add(stopField);
              bottomPanel.add(stepField);
              bottomPanel.add(startLabel);
              bottomPanel.add(stopLabel);
              bottomPanel.add(stepLabel);
              bottomPanel.add(goButton);
              goButton.addActionListener(this);
              bottomPanel.add(clearButton);
              clearButton.addActionListener(this);
              clearText = true;
              //set layouts for the Frame and Panels
              setLayout(new BorderLayout());
              topPanel.setLayout(new GridLayout(4, 4, 10, 10));
              bottomPanel.setLayout(new GridLayout(3, 3, 5, 5));
              //construct the Display
              for(int i = 0; i <= 15; i++)
                        topDisplay[i] = new TextArea(null, 3, 5, 3);
                        topDisplay.setText(String.valueOf(i+1));
                        topDisplay[i].setEditable(false);
                        topPanel.add(topDisplay[i]);
              //add components to frame
              add(topPanel, BorderLayout.NORTH);
              add(bottomPanel, BorderLayout.CENTER);
              //allow the x to close the application
              addWindowListener(new WindowAdapter()
                        public void windowClosing(WindowEvent e)
                                  System.exit(0);
                   } //end window adapter
         public static void main(String args[])
              Checkerboard f = new Checkerboard();
              f.setTitle("Checkerboard Array");
              f.setBounds(50, 100, 300, 400);
              f.setLocationRelativeTo(null);
              f.setVisible(true);
         } //end main
         public void actionPerformed(ActionEvent e)
              //test go
              String arg = e.getActionCommand();
              //go button was clicked
              if(arg.equals("Go"))
                   //convert data in TextField to int
                   int start = Integer.parseInt(startField.getText());
                   int stop = Integer.parseInt(stopField.getText());
                   int step = Integer.parseInt(stepField.getText());
                   if((start <= 1) && (start > 16))
                        JOptionPane.showMessageDialog(null, "You must enter start between 1 and 16", "Error", JOptionPane.ERROR_MESSAGE);
                        startField.setText(" ");
                        startField.requestFocus();
                   if ((stop < 1) && (stop > 16))
                        JOptionPane.showMessageDialog(null, "You must enter stop between 1 and 16", "Error", JOptionPane.ERROR_MESSAGE);
                        stopField.setText(" ");
                        stopField.requestFocus();
                   if ((step < 1) && (step > 16))
                        JOptionPane.showMessageDialog(null, "You must enter step between 1 and 16", "Error", JOptionPane.ERROR_MESSAGE);
                        stepField.setText(" ");
                        stepField.requestFocus();
                   if (start < stop)
                        JOptionPane.showMessageDialog(null, "Stop cannot be larger than start", "Error", JOptionPane.ERROR_MESSAGE);
                        startField.setText(" ");
                        stopField.setText(" ");
                        stepField.setText(" ");
                        startField.requestFocus();
                   for(int i = 0; i <=16; i++)
                   topDisplay[i].setBackground(Color.blue);
                   for(int i = start; i <= stop; step++)
                   topDisplay[i].setBackground(Color.yellow);
              } //end the if go
              //clear button was clicked
              if(arg.equals("Clear"))
                   clearText = true;
                   startField.setText("");
                   stopField.setText("");
                   stepField.setText("");
                   first = true;
                   setBackground(Color.white);
                   startField.requestFocus();
              } //end the if clear
         }//end action listener
    }//end class

    got the yellow boxes to come up but just one box.....so is there something wrong with my yellow set background because I am not seeing any more errors
    //packages to import
    import javax.swing.JOptionPane;
    import java.awt.*;
    import java.awt.event.*;
    public class Checkerboard extends Frame implements ActionListener
         private Panel topPanel;
         private TextArea topDisplay[];
         private Panel bottomPanel;
         private TextField startField = new TextField(10);
         private TextField stopField = new TextField(10);
         private TextField stepField = new TextField(10);
         private Label startLabel = new Label ("Start");
         private Label stopLabel = new Label ("Stop");
         private Label stepLabel = new Label ("Step");
         private Button goButton;
         private Button clearButton;
         private boolean clearText;
         private boolean first;
         private int start;
         private int stop;
         private int step;
         //constructor methods
         public Checkerboard()
              //construct components and initialize beginning values
              topPanel = new Panel();
              topDisplay = new TextArea[16];
              goButton = new Button("Go");
              clearButton = new Button("Clear");
              first = true;
              bottomPanel = new Panel();
              int start = 0;
              int stop = 0;
              int step = 0;
              bottomPanel.add(startField);
              bottomPanel.add(stopField);
              bottomPanel.add(stepField);
              bottomPanel.add(startLabel);
              bottomPanel.add(stopLabel);
              bottomPanel.add(stepLabel);
              bottomPanel.add(goButton);
              goButton.addActionListener(this);
              bottomPanel.add(clearButton);
              clearButton.addActionListener(this);
              clearText = true;
              //set layouts for the Frame and Panels
              setLayout(new BorderLayout());
              topPanel.setLayout(new GridLayout(4, 4, 10, 10));
              bottomPanel.setLayout(new GridLayout(3, 3, 5, 5));
              //construct the Display
              for(int i = 0; i <= 15; i++)
                        topDisplay[i] = new TextArea(null, 3, 5, 3);
                        topDisplay.setText(String.valueOf(i+1));
                        topDisplay[i].setEditable(false);
                        topPanel.add(topDisplay[i]);
              //add components to frame
              add(topPanel, BorderLayout.NORTH);
              add(bottomPanel, BorderLayout.CENTER);
              //allow the x to close the application
              addWindowListener(new WindowAdapter()
                        public void windowClosing(WindowEvent e)
                                  System.exit(0);
                   } //end window adapter
              public static void main(String args[])
                        Checkerboard f = new Checkerboard();
                        f.setTitle("Checkerboard Array");
                        f.setBounds(50, 100, 300, 400);
                        f.setLocationRelativeTo(null);
                        f.setVisible(true);
                   } //end main
                   public void actionPerformed(ActionEvent e)
                        boolean done = false;
                        //test go
                        String arg = e.getActionCommand();
                        //go button was clicked
                        if(arg.equals("Go"))
                   //convert data in TextField to int
                   int start = Integer.parseInt(startField.getText());
                   int stop = Integer.parseInt(stopField.getText());
                   int step = Integer.parseInt(stepField.getText());
                   while(!done)
                        try
                             if((start <= 1) && (start > 16)) throw new NumberFormatException();
                             else done = true;
                        } //end try
                        catch (NumberFormatException f)
                             JOptionPane.showMessageDialog(null, "You must enter start between 1 and 16", "Error", JOptionPane.ERROR_MESSAGE);
                             startField.setText(" ");
                             startField.requestFocus();
                        } //end catch
                        try
                             if ((stop < 1) && (stop > 16)) throw new NumberFormatException();
                             else done = true;
                        } //end try
                        catch (NumberFormatException f)
                             JOptionPane.showMessageDialog(null, "You must enter stop between 1 and 16", "Error", JOptionPane.ERROR_MESSAGE);
                             stopField.setText(" ");
                             stopField.requestFocus();
                        } //end catch
                        try
                             if ((step < 1) && (step > 16)) throw new NumberFormatException();
                             else done = true;
                        } //end try
                        catch (NumberFormatException f)
                             JOptionPane.showMessageDialog(null, "You must enter step between 1 and 16", "Error", JOptionPane.ERROR_MESSAGE);
                             stepField.setText(" ");
                             stepField.requestFocus();
                        } //end catch
                        try
                             if (start > stop) throw new NumberFormatException();
                             else done = true;
                        } //end try
                        catch (NumberFormatException f)
                             JOptionPane.showMessageDialog(null, "Stop cannot be larger than start", "Error", JOptionPane.ERROR_MESSAGE);
                             startField.setText(" ");
                             stopField.setText(" ");
                             stepField.setText(" ");
                             startField.requestFocus();
                        } //end catch
              } //end while
                        for(int i = 0; i <=15; i++)
                        topDisplay[i].setBackground(Color.blue);
                        for(int i = start; i <= stop; step++)
                        topDisplay[i].setBackground(Color.yellow);
                   } //end the if go
                   //clear button was clicked
                   if(arg.equals("Clear"))
                        clearText = true;
                        startField.setText("");
                        stopField.setText("");
                        stepField.setText("");
                        first = true;
                        setBackground(Color.white);
                        startField.requestFocus();
                   } //end the if clear
         }//end action listener
    }//end class

Maybe you are looking for

  • Error in VT04 - Doesn't create Shipments

    Error in VT04 - Doesn't create Shipments We have this function module that automatically creates delivery and shipment base from the Goods Receipt. The problem is it doesn't createe shipment document because the delivery doc doesn't exists. Upop debu

  • ITS_CANT_LOAD_INCLUDE

    Hi Folks, when publishing the webGui according to the docu i want to login to webgui and i get that dump. the dump says the template templates/webgui/dm/generator.html" has syntax-errors. i'm new to its and just want to combine webdynpro applications

  • FF lost all my settings inc the download counter. I use to watch online videos & be able to download now I have not option in toolbar any ideas plz nor no timer

    MY FF PLAYED UP AT THE WEEKEND AND IVE LOST ALL BOOKMARKS ALSO ON THE TOOLBAR YOU HAVE THE DOWNLOAD ARROW WELL BESIDE THAT USE TO BE A DOWNLOAD TIMER/COUNTER FOR WHEN YOU WATCHED VIDEOS YOU CLICK THE DOWNLOAD AND THE COUNTER WOULD WORK. I HAVE NO COU

  • Template-tdf

    hello.. i found some of template file when i want to design report that is extension is tdf if i want to design special template which the software that is enable me to do that in order to use that in my report that is built in developer 6i.? thanks

  • Can I activate a Sprint Blackberry 8830 on the telus network?

    Searching through ebay, the sprint version of this phone sells for a lot cheaper then the telus version. It says it is unlocked, so will i be able to activate it through telus?