Trying to draw multiple bars

Hi I'm pretty new to this but here's my question.
I have a Panel and I need to draw around 20 bars or rectangles on there.
So I made an array of rectangles and figured a for loop should work .
But after I run it my frame will pop up but none of my buttons will
show up and I keep getting a null pointer execption and the program will just die.
Here's the piece of code that should get the job done, but keeps screwing up.
public void draw( Graphics g ) {
    for ( int i = 0; i < rectangles.length; i++ )
        rectangles.draw(g);
     g.setColor(c);
     int xc = (int) (5 + 100 * Math.sin(6.28*t/n));
     int yc = (int) (5 + 100 * Math.sin(6.28*t/n));
     g.fillRect(xc, yc, sz, siz);
Can somebody help me figure out where I'm screwing up?
Thanks alot

Hard to tell from this code. I'd have a wild guess
and say the array has holes in it. Does
rectangles[0] have a value for example? Inside the
loop put System.out.println("i="+i);  and see how far it get before it blows up.Thanks dude but unfornatly it does the same thing.
As far whether rectangles[0] have a value, I assumed when I wrote
the loop that as long as it increments to the end of the array it would keep drawing
rectangles, so rectangles[0] should be the very first bar that's drawn, unless I royaly
screwed up somewhere.
Here's the class that houses that piece of code.
public class AnimatedSquare implements Animator {
        private int sz; // this is to determine the width
        private int siz;//for the height
        private Color c;
        private int n;
        private Animation[] rectangles;
        public AnimatedSquare(int sz1, Color c1, int n1, int siz1) {
               sz = sz1;
               c = c1;
               n = n1;
               siz = siz1;
        public Animation getAnimation() {
               return new ASquare();
        public String brief() {return "Animated Square";}
        public String verbose() {return brief();};
        private class ASquare implements Animation {
               private double t;
               public ASquare() {
                    t = 0;
              rectangles = new Animation[30]; // 30 rectangles
            public void draw( Graphics g ) {
                     for ( int i = 0; i < rectangles.length; i++ )
                   rectangles.draw(g);
               g.setColor(c);
                    int xc = (int) (5 + 100 * Math.sin(6.28*t/n));
                    int yc = (int) (5 + 100 * Math.sin(6.28*t/n));
               g.fillRect(xc, yc, sz, siz);
          public Animation next() {
               t = t + 1;
               return this;
          public String brief() { return "Square " + t;};
          public String verbose() {return brief();}

Similar Messages

  • Anybody know where I can find Draw Multiple Lines.vi?

    I don't mean the actual function itself. I know you just right-click and scroll through the menus for that. But I want to find a VI that showcases how the Draw Multiple Lines.vi is used. As of yet I can't find one anywhere. I've read the Detailed Help that Labview provides when I look at the function under Context Help, and it mostly makes sense. The only thing that's not working is how to implement the array that provides the line points into the function. I tried connecting a 1D array to the function and it was no dice. I get the quentessential error:
    You have connected two terminals of a different type. The source is 1D array of double. The sink is 1D array of cluster of 2 elements.
    So I know there is a special array called a Cluster Array, I think. Does it want me to attach that instead?

    ShogunOrta wrote:
    I just want to programmatically draw a line on the Front Panel from point A to point B. That's all.
    You can only do it with the restriction that it has to be bounded to a picture indicator. To draw anywhere on the front panel, we would need this idea implemented.
    A plain 1D array does not define points because each point has an x and a y.  Hierarchical data structure are actually quite easy once you play a little bit with them.

  • Getting error while trying to delete multiple rows

    Hi Experts,
    Working in jdev 11.1.1.3.0 with ADF BC and rich faces.
    i am trying to delete multiple records from the table, everything is working fine if i use filter or not using horizontal scroll bar of the table. if i try to delete last records on the table and the records are deleting from UI and from the DB also, but i am getting error like
    ADFv:Count not find row:_$<to-calc>$_with key:oracle.jbo.key[2333] inside parent: XxwfsAvcardXXXXXXXVO1Iterator with key:null
    I have changed my method with the below link
    Re: JDev 11g-Multiple Row Selection Table-Ctrl+A error
    but till i am getting the same error:
    Method:
    public void deleteRec(ActionEvent actionEvent) {
    // Add event code here...
    RowKeySet rowKeySet = (RowKeySet)this.embossTB.getSelectedRowKeys();
    CollectionModel cm = (CollectionModel)this.embossTB.getValue();
    Row specRow = null;
    ArrayList rowList = new ArrayList();
    int listLength = 0;
    ArrayList<Number> printReqLST=new ArrayList<Number>();
    ViewObject vo1=null;
    boolean flag=false;
    for (Object facesTreeRowKey : rowKeySet) {
    cm.setRowKey(facesTreeRowKey);
    JUCtrlHierNodeBinding rowData = (JUCtrlHierNodeBinding)cm.getRowData();
    specRow = rowData.getRow();
    rowList.add(specRow);
    listLength++;
    for (int index = 0; index < listLength; index++){
    specRow = (Row)rowList.get(index);
    Number printReqID = (Number)specRow.getAttribute("PrintRequestId");
    String PrintState = specRow.getAttribute("PrintState").toString();
    if (PrintState.equalsIgnoreCase("PRINTED")) {
    System.out.println("cann't delete");
    FacesContext fctx = FacesContext.getCurrentInstance();
    FacesMessage message =
    new FacesMessage("Cann't Delete the selected row:" + printReqID);
    message.setSeverity(FacesMessage.SEVERITY_ERROR);
    fctx.addMessage(null, message);
    } else {
    System.out.println("delete");
    flag=true;
    specRow.remove();
    if(flag){
    System.out.println("before commit");
    commitRows();
    Can any one help me....

    Can any one help me...
    i written logic in AM but still i am facing the same issue.
    can any one help me, is this is bug or coding issue.
    If i am not doing scroll down and trying to delete rows then there is no error.... only error is coming when i scroll down and try to delete.
    Method:
    public void deleteRec(ActionEvent actionEvent) {
    // Add event code here...
    RowKeySet rowKeySet = (RowKeySet)this.embossTB.getSelectedRowKeys();
    CollectionModel cm = (CollectionModel)this.embossTB.getValue();
    List<Row> rowsToDelete = new ArrayList<Row>();
    for (Object facesTreeRowKey : rowKeySet) {
    cm.setRowKey(facesTreeRowKey);
    JUCtrlHierNodeBinding rowData = (JUCtrlHierNodeBinding)cm.getRowData();
    Number printReqID = (Number)rowData.getAttribute("PrintRequestId");
    String PrintState=rowData.getAttribute("PrintState").toString();
    if (PrintState.equalsIgnoreCase("PRINTED")){
    System.out.println("cann't delete");
    FacesContext fctx = FacesContext.getCurrentInstance();
    FacesMessage message =
    new FacesMessage("Cann't Delete the selected row:" + printReqID);
    message.setSeverity(FacesMessage.SEVERITY_ERROR);
    fctx.addMessage(null, message);
    } else{
    System.out.println("delete");
    Row row1 = rowData.getRow();
    rowsToDelete.add(row1);
    // deletePrintRecords(printReqID);
    for (Row row : rowsToDelete){
    System.out.println("inside deleting rows");
    row.remove();
    //commitRows();
    System.out.println("After commit from am");
    public void commitRows(){
    // System.out.println("commit");
    DCIteratorBinding embossIter =
    ADFUtils.findIterator("XxwfsAvcardEmbossInterfaceVO1Iterator");
    ADFUtils.invokeEL("#{bindings.Commit.execute}");
    embossIter.getViewObject().executeQuery();
    AdfFacesContext.getCurrentInstance().addPartialTarget(embossTB);
    Edited by: user5802014 on Sep 3, 2010 11:47 AM
    Edited by: user5802014 on Sep 3, 2010 1:07 PM

  • I am trying to scan multiple pages from my scanner using a Mac and don't know how to

    Hi there,
    I am trying to scan multiple pages using HP Deskjet 3070A (Print Scan Copy) and it is all wireless using a Mac OSX 10.6 Snow Leopard and it won't let me. And I am trying to send this document via email.
    Can you offer advice as to how I can do this.
    Much appreciated.
    This question was solved.
    View Solution.

    Hi,
    Please refer manual for the printer and page 26 from link below.
    Although I am an HP employee, I am speaking for myself and not for HP.
    --Say "Thanks" by clicking the Kudos Star in the post that helped you.
    --Please mark the post that solves your problem as "Accepted Solution"

  • Photoshop CC: When I'm trying to draw a rectangle I can't fill it or create a stoke because there is a message telling me; "Could not complete your request because of a program error. What can I do?

    Photoshop CC: When I'm trying to draw a rectangle I can't fill it or create a stoke because there is a message telling me; "Could not complete your request because of a program error. What can I do?

    It is a mute point now. PSE12 finally failed to the point it locked up the MAC. I had to restore the MAC OS from backup to a point before the PSE12 update.
    The MAC now operates correctly and so does PSE12. I don't think I'll be updating PSE any time soon.

  • I am getting a error IO when trying to upload multiple images within wordpress using the flash uploader. I do not get the error when uploading using explorer. The error only appears if I try uploading using firefox....any ideas?

    I am getting a error IO when trying to upload multiple images within wordpress using the flash uploader. I do not get the error when uploading using explorer. The error only appears if I try uploading using firefox....any ideas?

    Logged the call with SAP who directed me to 'Define settings for attachments' in IMG and setting the 'Deactivate Java Applet' & 'Deactivate Attachment versioning' checkboxes - problem solved.

  • I am trying to attach multiple photos to an email from my ipad 2. I can see how to do it from the camera and camera roll option,but not from the photos program. What am I missing? Thanx so much!

    I am trying to attach multiple photos to an email using ipad 2. I can see how to do it using the camera and camera roll ap...
    But not using the photos ap..which is where the photos are. Any help would be appreciated.!

    In an album in Photos touch the Edit button and then touch the desired photos (up to 5). A blue check appears in each selected photo. Next touch the Share button at the upper left and select Mail. This starts a email with the photos attached.

  • Tries to connect multiple times at the same time a...

    Tries to connect multiple times at the same time after trying to reinstalling software.

    Hello,
    Assuming that you use a Web version (this information MUST be provided in any post), you have 2 ways to run reports:
    1. the Run_Report_Object built-in
    2. the Web.Show_Document() built-in
    Francois

  • How to draw multiple lines on same panel??

    hiya
    i would like to know how can I draw multiple lines on the same panel ?? I have already use repaint(); but it just come out the lastest line (say line 3) i draw .......those previous lines(say line 1 and 2) are disappear ........
    Thanks for your help mate

    http://www.java2s.com/ExampleCode/2D-Graphics/Line.htm

  • Hello Apple community... I am trying to combine multiple pdf's into one, using preview, but when I drag the additional pages they show up as separate documents.

    I am trying to combine multiple pdf's into one, using preview, but when I drag the additional pages they show up as separate documents.  When I drag the doc in a line would show up in the past, and if I went above th eline all was good.  It doesn't have a line, and no matter what I try I am having no success.
    Please help!

    According to an Apple Support article, unless there are unforeseen issues
    in file ownership or permissions, the combining of .PDFs should be simple.
    •OS X: Combining PDF documents using Preview - Apple Support
    There are a few variable and similar methods, some change with version
    of OS X in use; some vintage OS X may vary a little in the process...
    A variety of similar topics appear in search results, with terms:
    " mac os x combine pdf into one " such as this page shows...
    https://www.google.com/?gws_rd=ssl#q=mac%20os%20x%20combine%20pdf%20into%20one
    If the system is older than Mavericks there may be other methods to try.
    Suggestions are among linked results in the search. I see a few fair ones.
    •Here's another that offers generally similar suggestions...*  this info looks OK, extra links, do not:
    http://osxdaily.com/2014/06/27/how-to-join-multiple-pdf-files-into-a-single-pdf- document-in-mac-os-x/
    { note: avoid clicking on links to products in * this ^ page, since they likely will not help & may be adware prone }
    If you have a problem after trying other methods, based on an OS X
    your computer is running, post back with more exact information...
    Good luck & happy computing!
    edited

  • Can we draw multiple lines on a single CAShapeLayer?

    I want to draw multiple lines on a single layer of CAShapeLayer by UITouch. Is it possible?

    if they use the same appleID then you can do it at www.icloud.com

  • Trying to get multiple cell values within a geometry

    I am provided with 3 tables:
    1 - The GeoRaster
    2 - The geoRasterData table
    3 - A VAT table who's PK is the cell value from the above tables
    Currently the user can select a point in our application and by using the getCellValue we get the cell value which is the PK on the 3rd table and this gives us the details to return to the user.
    We now want to give the worst scenario within a given geometry or distance. So if I get back all the cell values within a given geometry/distance I can then call my other functions against the 3rd table to get the worst scores.
    I had a conversation open for this before where JeffreyXie had some brilliant input, but it got archived while I was waiting on Oracle to resolve a bug (about 7 months)
    See:
    Trying to get multiple cell values within a geometry
    If I am looking to get a list of cell values that interact with my geometry/distance and then loop through them, is there a better way?
    BTW, if anybody wants to play with this functionality, it only seems to work in 11.2.0.4.
    Below is the code I was using last, I think it is trying to get the cell values but the numbers coming back are not correct, I think I am converting the binary to integer wrong.
    Any ideas?
    CREATE OR REPLACE FUNCTION GEOSUK.getCellValuesInGeom_FNC RETURN VARCHAR2 AS
    gr sdo_georaster;
    lb blob;
    win1 sdo_geometry;
    win2 sdo_number_array;
    status VARCHAR2(1000) := NULL;
    CDP varchar2(80);
    FLT number := 0;
    cdl number;
    vals varchar2(32000) := null;
    VAL number;
    amt0 integer;
    amt integer;
    off integer;
    len integer;
    buf raw(32767);
    MAXV number := null;
    r1 raw(1);
    r2 raw(2);
    r4 raw(200);
    r8 raw(8);
    MATCH varchar2(10) := '';
    ROW_COUNT integer := 0;
    COL_COUNT integer := 0;
    ROW_CUR integer := 0;
    COL_CUR integer := 0;
    CUR_XOFFSET integer := 0;
    CUR_YOFFSET integer := 0;
    ORIGINY integer := 0;
    ORIGINX integer := 0;
    XOFF number(38,0) := 0;
    YOFF number(38,0) := 0;
    BEGIN
    status := '1';
    SELECT a.georaster INTO gr FROM JBA_MEGARASTER_1012 a WHERE id=1;
    -- first figure out the celldepth from the metadata
    cdp := gr.metadata.extract('/georasterMetadata/rasterInfo/cellDepth/text()',
    'xmlns=http://xmlns.oracle.com/spatial/georaster').getStringVal();
    if cdp = '32BIT_REAL' then
    flt := 1;
    end if;
    cdl := sdo_geor.getCellDepth(gr);
    if cdl < 8 then
    -- if celldepth<8bit, get the cell values as 8bit integers
    cdl := 8;
    end if;
    dbms_lob.createTemporary(lb, TRUE);
    status := '2';
    -- querying/clipping polygon
    win1 := SDO_GEOM.SDO_BUFFER(SDO_GEOMETRY(2001,27700,MDSYS.SDO_POINT_TYPE(473517,173650.3, NULL),NULL,NULL), 10, .005);
    status := '1.2';
    sdo_geor.getRasterSubset(gr, 0, win1, '1',
    lb, win2, NULL, NULL, 'TRUE');
    -- Then work on the resulting subset stored in lb.
    status := '2.3';
    DBMS_OUTPUT.PUT_LINE ( 'cdl: '||cdl );
    len := dbms_lob.getlength(lb);
    cdl := cdl / 8;
    -- make sure to read all the bytes of a cell value at one run
    amt := floor(32767 / cdl) * cdl;
    amt0 := amt;
    status := '3';
    ROW_COUNT := (WIN2(3) - WIN2(1))+1;
    COL_COUNT := (WIN2(4) - WIN2(2))+1;
    --NEED TO FETCH FROM RASTER
    ORIGINY := 979405;
    ORIGINX := 91685;
    --CALCUALATE BLOB AREA
    YOFF := ORIGINY - (WIN2(1) * 5); --177005;
    XOFF := ORIGINX + (WIN2(2) * 5); --530505;
    status := '4';
    --LOOP CELLS
    off := 1;
    WHILE off <= LEN LOOP
    dbms_lob.read(lb, amt, off, buf);
    for I in 1..AMT/CDL LOOP
    if cdl = 1 then
    r1 := utl_raw.substr(buf, (i-1)*cdl+1, cdl);
    VAL := UTL_RAW.CAST_TO_BINARY_INTEGER(R1);
    elsif cdl = 2 then
    r2 := utl_raw.substr(buf, (i-1)*cdl+1, cdl);
    val := utl_raw.cast_to_binary_integer(r2);
    ELSIF CDL = 4 then
    IF (((i-1)*cdl+1) + cdl) > len THEN
    r4 := utl_raw.substr(buf, (i-1)*cdl+1, (len - ((i-1)*cdl+1)));
    ELSE
    r4 := utl_raw.substr(buf, (i-1)*cdl+1, cdl+1);
    END IF;
    if flt = 0 then
    val := utl_raw.cast_to_binary_integer(r4);
    else
    val := utl_raw.cast_to_binary_float(r4);
    end if;
    elsif cdl = 8 then
    r8 := utl_raw.substr(buf, (i-1)*cdl+1, cdl);
    val := utl_raw.cast_to_binary_double(r8);
    end if;
    if MAXV is null or MAXV < VAL then
    MAXV := VAL;
    end if;
    IF i = 1 THEN
    VALS := VALS || VAL;
    ELSE
    VALS := VALS ||'|'|| VAL;
    END IF;
    end loop;
    off := off+amt;
    amt := amt0;
    end loop;
    dbms_lob.freeTemporary(lb);
    status := '5';
    RETURN VALS;
    EXCEPTION
        WHEN OTHERS THEN
            RAISE_APPLICATION_ERROR(-20001, 'GENERAL ERROR IN MY PROC, Status: '||status||', SQL ERROR: '||SQLERRM);
    END;

    Hey guys,
    Zzhang,
    That's a good spot and as it happens I spotted that and that is why I am sure I am querying that lob wrong. I always get the a logic going past the total length of the lob.
    I think I am ok using 11.2.0.4, if I can get this working it is really important to us, so saying to roll up to 11.2.0.4 for this would be no problem.
    The error in 11.2.0.3 was an internal error: [kghstack_underflow_internal_3].
    Something that I think I need to find out more about, but am struggling to get more information on is, I am assuming that the lob that is returned is all cell values or at lest an array of 4 byte (32 bit) chunks, although, I don't know this.
    Is that a correct assumption or is there more to it?
    Have either of you seen any documentation on how to query this lob?
    Thanks

  • Getting Error while trying to enter multiple records using PA70

    Hi all,
    While trying to enter multiple records for a custom infotype using transaction PA70,
    the system asked to provide details of the custom infotype in T588Q and T588r tables after giving the details i'm able to enter into the custom infotype screen but the Personnel number is defaultly taken as
    zero and im not able to change the value and if i click save after entering the other details it is throwing an error telling that Infotype doesnt exist.
    Please Help..
    Thanks & Regards,
    Kumar Madduru

    Hi,
    Let us know the detailed error text. Probably you haven't included the infotype to maintain in Fast Entry or doesn't have the authorization.
    Good Luck
    Om

  • Just bought a new iphone4 and was loading os6 and now it won't turn on. the apple glows like it is starting up, then the screen goes black and then repeats the same process over and over. i have tried to reboot multiple times now

    just bought a new iphone4 and was loading os6 and now it won't turn on. the apple glows like it is starting up, then the screen goes black and then repeats the same process over and over. i have tried to reboot multiple times now

    I am assuming the phone was working prior to you installing IOS 6? Did you use itunes to install IOS 6 or just run from the phone?
    When I tried to do the Over The Air update to IOS6 on my iPhone 4, it errored out and I had to connect it to iTunes and select "Restore" from the summary screen after iTunes finds the phone is connected. If this works for you, it will go through a couple of reboots that take a few minutes to complete. It should then give you the option to start with a fresh new phone or to use one of your previous backups to load your contacts and other information, provided you have backed up the phone previously.
    I hope this helps you my friend!

  • Problem with Loader, trying to load multiple png files, error 1069 on the contentLoaderInfo

    Hi helpers !@
    im trying to load multiple external png files from a folder.  the path for the images comes from an xml attribute and i got no problem with the path. The error message pops on when i try to add the loader into an array for later use and then when im done remove each child i created.  There is something in my pratice that is not ok , i meen i know im wrong with at some point !  Duh theres an Error message for each loader i create .. .
    ReferenceError: Error #1069: Property Loader not found on flash.display.LoaderInfo and there is no default value.
    here some code  , pls  guide me !
    function affichageM(){
      var nodeM:XML;
    for each ( nodeM in listeM ){
       var reqM:String = localLogoM + nodeM.attribute("icon_max2");
       var imageLoaderJ = new Loader();
       imageLoaderJ.contentLoaderInfo.addEventListener(Event.INIT,addM);
       imageLoaderJ.load(new URLRequest(reqM));
         // just counting for fun
       iNodeM ++;
    function addM(e:Event){
    try { var l_img:Loader = Loader(e.currentTarget.Loader);
           l_img.name = "imageLoaderJ" + mc_ArrayImg.length().toString() ;
           l_img.visible = false;
           mc_ArrayImg.push(l_img);
           mc_Jour.addChild(l_img);
             //calling the fucntion that will animate all img in the array and had some text to them.....
          drawMyImg(mc_ArrayMImg.length()-1);
    catch (error:Error) {
           //just counting errors for fun
          iErreurM++;
            var errorMessage:TextField = new TextField();
            errorMessage.autoSize = TextFieldAutoSize.LEFT;
            errorMessage.textColor = 0xFF0000;
            errorMessage.text = error.message + " " +  mc_Jour.numChildren + " " + mc_ArrayImg.length;
            errorMessage.x = 10*iErreurM;
            addChild(errorMessage);
            return;

    Hi, I'm not sure you are on the correct forum. This is the Flash Player forum. When you first open your thread, look to your right "More like This" and perhaps one of those forums would be helpful. Perhaps the Flash forum?
    Thanks,
    eidnolb

Maybe you are looking for

  • Authorization error while attaching document in ME22N

    Hi, Scenario 1: I attach a document in ME22N and then save it. Result: I get an authorization error. Error is: "You have no authorization for extensions (activity03)" Scenario 2: I just make a change (say in price) without attaching any document and

  • My Mac Mini is getting feedback from External HDD

    I am running a external WD 2T Caviar through SATA docking station. I am getting serious HDD feedback throught my speakers. I am using a sheilded Monster Analog stereo cable and it cuts the noise down a little. I have noticed that when playing audio t

  • Is a Mac the right way to go?

    Hello All I need your knowledge and wisdom to help me with a business IT problem I have. I run a small online company with 3 other staff. We buy and sell items online through a third party website. If you can image we are a company that sells through

  • Self Registration error while installing BPC on windows 7

    Hi all, While I am installing BPC NW 7.0 client on my Windows 7(64 bit), I am getting following popup Self Registration Error 1. C:\WINDOWS\SYSWOW64\asycfilt.dll                                         The Specified procedure could not be found The s

  • Automatic Append Message Output for PO

    hello all, My scenario is after creating PO completely then go to message output through Messages button on icon row. On message output screen, there's no output item available. Then I must add NEU output type manually. Normally there's output type i