Errors dont know what is wrong!

Errors dont know what is wrong!
import java.awt.*;
import javax.swing.*;
import java.awt.geom.*;
import java.awt.event.MouseListener;
import java.awt.event.*;
public class SquareShape extends Piece
{private Rectangle2D.Double _square1, _square2, _square3, _square4;
private int xLoc=80, yLoc=0, size=19, space=1;
private smallPiece [][] rectangle;
public SquareShape(smallPiece[][] rect)
{super(Color.red);
_square1 = new Rectangle2D.Double(xLoc,yLoc,size,size);
_square2 = new Rectangle2D.Double(xLoc,yLoc+size+space,size,size);
_square3 = new Rectangle2D.Double(xLoc+size+space,yLoc,size,size);
_square4 = new Rectangle2D.Double(xLoc+size+space,yLoc+size+space,size,size);
rectangle= rect;}
public void setXLocation(int x)
{_square1.setFrame(xLoc+x,yLoc,size,size);
_square2.setFrame(xLoc+x,yLoc+size+space,size,size);
_square3.setFrame(xLoc+size+space+x,yLoc,size,size);
_square4.setFrame(xLoc+size+space+x,yLoc+size+space,size,size);
xLoc=xLoc+x;}
public void setYLocation(int y)
{_square1.setFrame(xLoc,yLoc+y,size,size);
_square2.setFrame(xLoc,yLoc+size+space+y,size,size);
_square3.setFrame(xLoc+size+space,yLoc+y,size,size);
_square4.setFrame(xLoc+size+space,yLoc+size+space+y,size,size);
yLoc=yLoc+y;}
public boolean moveOneStep()
{if(_square2.getY()+size>=440||_square4.getY()>=440)
return false;
else
if(rectangle[21-((int)(_square2.getY()+1))/20][9-((int)(_square2.getX()+1))/20]!=null || rectangle[21-((int)(_square4.getY()+1))/20][9-((int)(_square4.getX()+1))/20]!=null)
{return false;}
else
{setYLocation(20);
return true;}}
public int[][] getLocs()
{int[][] locs= new int[4][2];
locs[0][0]= ((int)(_square1.getY()+1))/20;
locs[0][1]= ((int)(_square1.getX()+1))/20;
locs[1][0]= ((int)(_square2.getY()+1))/20;
locs[1][1]= ((int)(_square2.getX()+1))/20;
locs[2][0]= ((int)(_square3.getY()+1))/20;
locs[2][1]= ((int)(_square3.getX()+1))/20;
locs[3][0]= ((int)(_square4.getY()+1))/20;
locs[3][1]= ((int)(_square4.getX()+1))/20;
System.out.println(locs[0][0]+" "+locs[0][1]+" "+locs[1][0]+" "+locs[1][1]+" "+locs[2][0]+" "+locs[2][1]+ " "+locs[3][0]+" "+locs[3][1]);
return locs;}
public boolean contains(int x, int y)
{if(_square3.contains(x,y)||_square4.contains(x,y))
return true;
else
return false;}
public void fill(Graphics2D g2)
super.fill(g2);
g2.fill(_square1);
g2.fill(_square2);
g2.fill(_square3);
g2.fill(_square4);}
import java.awt.geom.*;
import java.awt.*;
import javax.swing.JPanel;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.awt.event.*;
public class TetrisPanel extends JPanel
{private Factory _pieceFact;
private Piece currentPiece;
private Timer _timer;
private int Interval =500;
private smallPiece [][] locationArray;
public TetrisPanel()
{setBackground(Color.white);
locationArray = new smallPiece[22][10];
_pieceFact = new Factory(locationArray);
currentPiece = _pieceFact.newPiece();
_timer = new Timer(Interval, new TimerListener());
_timer.start();
public void paintComponent(Graphics g)
{super.paintComponent(g);
Graphics2D g2 = (Graphics2D)g;
currentPiece.fill(g2);
for(int row =0; row<22; row++)
for(int col =0; col<10; col++)
if(locationArray[row][col]!=null)
{locationArray[row][col].fill(g2);}}
public void createPiece()
{currentPiece =_pieceFact.newPiece();
repaint();}
public class TimerListener implements ActionListener{
public void actionPerformed(ActionEvent e)
if(currentPiece.moveOneStep()==true)
{repaint();
currentPiece.getLocs();}
else
{int[][]ar = currentPiece.getLocs();
for(int rows=0; rows<ar.length; rows++)
{locationArray[22-ar[rows][0]][10-ar[rows][1]] = new smallPiece(ar[rows][1]*20,ar[rows][0]*20, currentPiece.getColor());}
createPiece();
repaint();}
}the error
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 22
     at TetrisPanel$TimerListener.actionPerformed(TetrisPanel.java:51)
     at javax.swing.Timer.fireActionPerformed(Timer.java:271)
     at javax.swing.Timer$DoPostEvent.run(Timer.java:201)
     at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
     at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
     at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
     at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
     at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
     at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
     at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 22
     at SquareShape.moveOneStep(SquareShape.java:38)
     at TetrisPanel$TimerListener.actionPerformed(TetrisPanel.java:45)
     at javax.swing.Timer.fireActionPerformed(Timer.java:271)
     at javax.swing.Timer$DoPostEvent.run(Timer.java:201)
     at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
     at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
     at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
     at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
     at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
     at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
     at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

Errors dont know what is wrong!You read the stack trace from the top down, looking out for the first line that refers to your code.
java.lang.ArrayIndexOutOfBoundsException: 22This means that you are using something as an array index (some variable, perhaps) and it has a value of 22, but the array itself is not that big.
at TetrisPanel$TimerListener.actionPerformed(TetrisPanel.java:51This tells you exactly where the bad array access is taking place. Only you know which line 51 is - and it's good form to tell the rest of us when you post - but, at a wild guess, I'd say it was that line within the for loop that assigns new values to the locationArray.
Use System.out.println() to check the values of the variables (or expressions) you use to access the array. Also check the length of the various arrays involved.
(If I were you, I'd consider using a bit more indentation in your code. Especially where constructs are nested.)

Similar Messages

  • My ipad automatically jumps from one app to other. it automatically types things randomly. i dont know what it wrong. Have shown it in a service center. they have done factory reset but problem still persist.

    my ipad automatically jumps from one app to other. it automatically types things randomly. i dont know what it wrong. Have shown it in a service center. they have done factory reset but problem still persist.

    Likley a defective touchscreen.

  • I just installed photoshop but I dont know what is wrong it keep shutdown itself.

    dunno whats wrong. keep shutdown itself.

    Due to the current unavailability of clairvoyants and mind-readers in the forum, we respectfully request you supply sensible, complete details.
    BOILERPLATE TEXT:
    Note that this is boilerplate text.
    If you give complete and detailed information about your setup and the issue at hand,
    such as your platform (Mac or Win),
    exact versions of your OS, of Photoshop (not just "CS6", but something like CS6v.13.0.6) and of Bridge,
    your settings in Photoshop > Preference > Performance
    the type of file you were working on,
    machine specs, such as total installed RAM, scratch file HDs, total available HD space, video card specs, including total VRAM installed,
    what troubleshooting steps you have taken so far,
    what error message(s) you receive,
    if having issues opening raw files also the exact camera make and model that generated them,
    if you're having printing issues, indicate the exact make and model of your printer, paper size, image dimensions in pixels (so many pixels wide by so many pixels high). if going through a RIP, specify that too.
    etc.,
    someone may be able to help you (not necessarily this poster, who is not a Windows user).
    a screen shot of your settings or of the image could be very helpful too.
    Please read this FAQ for advice on how to ask your questions correctly for quicker and better answers:
    http://forums.adobe.com/thread/419981?tstart=0
    Thanks!

  • HT5569 hi my question is about my iphone 5 is not working properly i have installed iso 7 latest version but dont know what is wrong with it?

    my starts siri by it self and when i desable siri so voice control starts talking even i didn't touch my fone its operating by its self in the middle of talking on fone or not using it. sometimes the home key is not working at all. it stuck and i have to rebot or restart it again. i don't know its technical problem or software problem. i bought this iphone 5 on applestore.com in january 2013. this problem was started in may 2013 but was not so often and from september upto now its irrateting me so badly. sometimes it doesn't work at all and sometimes it didnt recognize my apple ID to sign in app store or itunes.
    how fix this problem any one can tell me plzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
    thank you

    Hi Karneet,
    Thanks for visiting Apple Support Communities.
    See this articles for some troubleshooting help, if your iPhone isn't detected by iTunes or Windows:
    iPod: Appears in Windows but not in iTunes
    http://support.apple.com/kb/ts1363
    iPod not recognized in 'My Computer' and in iTunes for Windows
    http://support.apple.com/kb/ts1369
    Best,
    Jeremy

  • I Dont Know What's Wrong .

    Ok , so I got my iPhone 5 about a week ago . And my friend has had her iPod touch 4th generation for a while . So she told me to use iMessage . She helped me turn it on and everything . And also told me what should happen like how the "SEND" button should be the color Blue when I use iMessage . So I turned it on and got it set . But the "SEND" button doesnt turn Blue . And she cant send messages to my email address . What Can I Do ?

    http://support.apple.com/kb/HT5538
    http://support.apple.com/kb/TS4268
    Check those.

  • Dont know what is wrong

    I connect my ipod nano to my laptop and it charges. But it is not being updated in itunes. None of the new songs that I put on itunes are being updated onto my ipod. Itunes is not recognizing the ipod. I used to plug in my ipod and itunes would pop up and it would update automaticly but now I have to click on itunes to get it started. What can I do?

    See if any of these articles help.
    Windows XP cannot detect an iPod.
    USB drivers are not installed properly or are out of date.
    iTunes 7 doesn't recognize the iPod.
    iPod not recognized on a Windows laptop.

  • I keep trying to install apps in app store and to buy an in app purchase and i keep getting "AN UNKNOWN ERROR HAS OCCURRED" its happenned since lastnight i dont know whaTS WRONG

    SICE LAST NIGHT I CANT GET ANYTHNG OFF THE APP STORE, MY PHONE HAS 4.3.3 AND IS JAILBROKEN I CONNETED TO AN OPEN WIFI LAST NIGHT BUT I DONT KNOW WHAT HAS BEEN MY DOWNFALL!

    First, turn off your CAPS lock.  Typing in all CAPS is considered screaming/yelling and many will simply ignore your posting.
    Are you currently having issues?  Is it when trying to purchase only on the device?  Are you able to complete purchases via iTunes on your computer?

  • I tried to update my ipod but then it didnt work saying that an unknow error has occured, now itunes is not recognising that an ipod has been plugged in and the picture that comes up when you first get it is on my screen, i dont know what to do?

    i tried to update my ipod but then it didnt work saying that an unknown error has occured, now itunes is not recognising that an ipod has been plugged in and the picture that comes up when you first get it (an arrow leading to the itunes sign) is on my screen, i dont know what to do?

    Error 1604
    This error is often related to USB timing. Try changing USB ports, using a different dock connector to USB cable, and other available USB troubleshooting steps (troubleshooting USB connections. If you are using a dock, bypass it and connect directly to the white Apple USB dock connector cable. If the issue persists on a known-good computer, the device may need service.
    If the issue is not resolved by USB isolation troubleshooting, and another computer is not available, try these steps to resolve the issue:
    Connect the device to iTunes, confirm that the device is in Recovery Mode. If it's not in Recovery Mode,put it into Recovery Mode.
    Restore and wait for the error.
    When prompted, click OK.
    Close and reopen iTunes while the device remains connected.
    The device should now be recognized in Recovery Mode again.
    Try to restore again.
    If the steps above do not resolve the issue, try restoring using a known-good USB cable, computer, and network connection.
    Error 1600, 1601, 1602
    Follow the steps listed above for Error 1604. This error may also be resolved by disabling, deactivating, or uninstalling third-party security, antivirus, and firewall software. See steps in this article for details on troubleshooting security software.

  • Everytime i try to download itunes it says rolling back action and error . i dont know what to do please help . P.S. i have windows 8

    everytime i try to download itunes it says rolling back action and error . i dont know what to do please help . P.S. i have windows 8

    Hello there Unicornbarf534,
    Thank you for using Apple Support Communities.
    It sounds like you are unable to successfully install iTunes. I recommend the troubleshooting instructions in this article named:
    Trouble installing iTunes or QuickTime for Windows
    http://support.apple.com/kb/HT1926
    Here is a general outline of where the troubleshooting will take you:
    General installation troubleshooting
    1. Empty your Temp directory and restart
    2. Completely remove iTunes and related components
    3. Install the latest version of iTunes
    Additional troubleshooting
    After performing each of the steps below, you will need to completely remove iTunes and related components and then install iTunes again to determine whether the issue is resolved.
    1. Make sure you have administrator account access
    2. Make sure your folder names don't contain strange characters
    3. Get the latest Windows updates
    4. Disable other conflicting software
    Additional Information
    If you only need to install QuickTime, or if iTunes installs but QuickTime installation did not complete
    Try downloading and installing the standalone version of QuickTime from http://www.apple.com/quicktime/download/. Be sure you download the version that does not include iTunes.
    If the steps outlined in this article don't help, you may be able to find a solution to your issue by searching the Microsoft support website.
    All the best,
    Sterling

  • I dont know what to do i try install itunes and this keeps coming up "itunes was not installed correctly. please reinstall itunes  error 7 (windows error 127)" what should i do?

    i dont know what to do i try install itunes and this keeps coming up "itunes was not installed correctly. please reinstall itunes  error 7 (windows error 127)" what should i do?

    For general advice see Troubleshooting issues with iTunes for Windows updates.
    The steps in the second box are a guide to removing everything related to iTunes and then rebuilding it which is often a good starting point unless the symptoms indicate a more specific approach. Review the other boxes and the list of support documents further down the page in case one of them applies.
    Your library should be unaffected by these steps but there is backup and recovery advice elsewhere in the user tip.
    tt2

  • Oh man i dont know whats wrong.... plz help urgent...

    i dont know whats wrong with my n900.... a couple of weeks before i tried to install nitroid gingerbread on my n900.... i did exactly what it said it was almost complete but the last step didnt complete so i left it like that..... i was using my mobile fine until one day i restarted my phone... when  it started it showed me 2 options (dont remember what the options were) although the 2nd one was power kernel something like that.... i chose 1st option after that it turned off when i startit again only nokia logo comes and it turns off by himself.... i thinki bricked my fone... but y didnt it happen when i was trying to install nitroid... plz help any way to fix it....
    P.S. I cant flash it either.. it doesnt go to usb mode anymore neither does it charge....
    Solved!
    Go to Solution.

    you could try to do the commands in flasher, connect the device while it is off and holding the U button down and see if the flasher will see it.

  • I keep getting an error when im answering questions for my chacha job i dont know what it means

    when i go to my dash bored on my chacha account i keep getting this error and i dont know what it means
    Error: "CustomXML()" don't work in Firefox/Mozilla toolbar version.
    Please use "setCustomXML(sName, sXMLData)" instead.
    that is the error i get
    == This happened ==
    Every time Firefox opened
    == like 2 weeks ago

    Hello Cassie.
    You may be having a problem with some Firefox add-on that is hindering your Firefox's normal behavior. Have you tried disabling all add-ons (just to check), to see if Firefox goes back to normal?
    Whenever you have a problem with Firefox, whatever it is, you should make sure it's not coming from one of your installed add-ons, be it an extension, a theme or a plugin. To do that easily and cleanly, run Firefox in [http://support.mozilla.com/en-US/kb/Safe+Mode safe mode] and select ''Disable all add-ons''. If the problem disappears, you know it's from an add-on. Disable them all in normal mode, and enable them one at a time until you find the source of the problem. See [http://support.mozilla.com/en-US/kb/Troubleshooting+extensions+and+themes this article] for information about troubleshooting extensions and theme. You can troubleshoot plugins the same way.
    If you want support for one of your add-ons, you'll need to contact its author.

  • TS1372 does anybody know what is wrong with the ipod when error 1437 is reported during the restore mode?

    does anybody know what is wrong with the ipod when error 1437 is reportedduring the restore cycle?

    Double check the connections on each end to make sure they are nice and snug. If possible, plug the Nano into another existing USB 2.0 port. 
    Also, with the iPod still connected, try resetting it. To do this, press and hold both the Select (Center) and Menu buttons (or the Volume Down and Sleep/Wake buttons on the 6G Nano) long enough for the Apple logo to appear.
    Then try restoring the iPod again.
    B-rock

  • Everytime i try downloading something from app store on my iphone it wont download, it keeps saying 'an unknown error has occured' i dont know what to do. iv tried restarting my phone. Help?

    everytime i try downloading something from app store on my iphone it wont download, it keeps saying 'an unknown error has occured' i dont know what to do. iv tried restarting my phone. Help?

    Sign Out of your Account... Close All Open Apps...  Perform a Reset... Try again...
    Reset
    Press and hold the Sleep/Wake button and the Home button at the same time for at least ten seconds, until the Apple logo appears. Release the Buttons.
    http://support.apple.com/kb/ht1430

  • My computer keeps freezing and i dont know whats wrong, or why it keeps freezing

    my computer keeps freezing and i dont know whats wrong, or why it keeps freezing

    It's happening on FIrefox too.  It's not a browser issue!  I have tried all, Chrome, FIrefox and IE and it freezes after about 5 minutes sometimes sooner, sometimes you get a little longer, but not much.

Maybe you are looking for