Need help with inserting element into a grid

Hi,
I'm trying to add an element in a 11x11 grid, but the program stop and give me 2 error (identified in the code) and I have no idea on what is wrong with those line. If anyone have any idea, suggestion or an other way to do this, I could use some help.
Thx
          for (int i = 0; i != NUMBER; ++i) {
                  int row = 2 + (int)(Math.random() * 10);
               int col = 2 + (int)(Math.random() * 10);
               int nb = 0 + (int)(Math.random() * 2);
               boolean horizontal = true;
               if (nb == 1)
                    horizontal = false;
               if (horizontal) {
                    if (row <= element.getDimension()) {  // error at this line
                         for (int j = 0; j != element[i].getDimension(); j++) {
                              grid[row + j][col]     = "X";
                    else {
                         for (int j = 0; j != element[i].getDimension(); j++) {
                              grid[row - j][col]     = "X";
               if (! horizontal) {
                    if (col <= element[i].getDimension()) { // error at this line
                         for (int j = 0; j != element[i].getDimension(); j++) {
                              grid[row][col + j]     = "X";
                    else {
                         for (int j = 0; j != element[i].getDimension(); j++) {
                              grid[row][col - j]     = "X";

My error is : Exception in thread "main" java.lang.NullPointerException
at Grid.<init><Grid.java:67>
at PrincTp1.main<PrincTp1.java:24>
That's my class element
public class Element {
// Attributs
     private int dimension;
     private boolean horizontal;
     private String name;
     private int row;
     private int col;
// Constructor
     public Element(int dimension_, String name_) {
          dimension = dimension_;
          name = name_;
     public Element() {
// getter/setter
     public void setDimension(int dimension_) {
          dimension = dimension_;
     public int getDimension() {
          return dimension;
     public void setHorizontal(boolean horizontal_) {
          horizontal = horizontal_;
     public boolean getHorizontal() {
          return horizontal;
     public void setNom(String name_) {
          name = name_;
     public String getName() {
          return name;
     public void setLigne(int row_) {
          row = row_;
     public int getRow() {
          return row;
     public void setCol(int col_) {
          col = col_;
     public int getCol() {
          return col;
     }

Similar Messages

  • Need Help with Inserting Timeline Markers

    Friends,
    I have not use my premiere element 3.2 since 2008 and forgot some of the procedures. now, I need help with the insertion of Timeline Markers. I did what the Help Page showed me. But the markers were not effective in the resulting DVD, or, even when viewing the video in the editing page as if thye were not there! Here is what I did:.
    1)  Click the Timeline button.
    2)  Click in an empty space in a video or audio track in the Timeline to make the Timeline active and deselect any clips.
    3)  Move the current-time indicator in the Timeline to the frame where I need the marker.
    4)  Click the Add Marker icon in the Timeline to place the Marker 5 times where I want them.
    5)  Verified that each Timeline Marker is present at the intended place.
    6)  Burned DVD
    7)  Can NOT jump to any of the intended Marker in the Resulting DVD during playback.
    The question is "What did I do wrong or didn't do?" It seems that I did the same before and worked! Please advise!
    Also, what are the significance of the Red line just below the Timeline and the yellow bars inside the video and audio frames. But after preforming Timeline/Render Work Area, they were all gone? What purposes do they serve and what is the significance of Rendering? Thank you for your help!
    I repeat the process and did a Rendering before making the DVD also. It did not help!
    Andy Lim

    Steve,
    Long time no talk! You used to help me out many times when the PE-1 through PE-3 came out. I was HOPING you would still be around and you are! You came through again this time! Many thanks to you.
    I use the Add DVD Scene button to insert the Markers. They are Green. Made a DVD and the markers work OK although ythey are "effective" during play back using the editing window.
    While that problem was solved, will you come back and answer the other two questions concerning Rendering and the Red/Yellow lines? I would appreciate it very much!
    Andy Lim
    ~~~~~~~~~~~~~~~~

  • Need help with INSERT and WITH clause

    I wrote sql statement which correctly work, but how i use this statment with INSERT query? NEED HELP. when i wrote insert i see error "ORA 32034: unsupported use of with clause"
    with t1 as(
    select a.budat,a.monat as period,b.vtweg,
    c.gjahr,c.buzei,c.shkzg,c.hkont, c.prctr,
    c.wrbtr,
    c.matnr,
    c.menge,
    a.monat,
    c.zuonr
    from ldw_v1.BKPF a,ldw_v1.vbrk b, ldw_v1.bseg c
    where a.AWTYP='VBRK' and a.BLART='RV' and a.BUKRS='8431' and a.awkey=b.vbeln
    and a.bukrs=c.bukrs and a.belnr=c.belnr and a.gjahr=c.gjahr and c.koart='D'
    and c.ktosl is null and c.gsber='4466' and a.gjahr>='2011' and b.vtweg='01'
    ,t2 as(
    select a.BUKRS,a.BELNR, a.GJAHR,t1.vtweg,t1.budat,t1.monat from t1, ldw_v1.bkpf a
    where t1.zuonr=a.xblnr and a.blart='WL' and bukrs='8431'
    ,tcogs as (
    select t2.budat,t2.monat,t2.vtweg, bseg.gjahr,bseg.hkont,bseg.prctr,
    sum(bseg.wrbtr) as COGS,bseg.matnr,bseg.kunnr,sum(bseg.menge) as QUANTITY
    from t2, ldw_v1.bseg
    where t2.bukrs=bseg.bukrs and t2.belnr=bseg.BELNR and t2.gjahr=bseg.gjahr and BSEG.KOART='S'
    group by t2.budat,t2.monat,t2.vtweg, bseg.gjahr,bseg.hkont,bseg.prctr,
    bseg.matnr,bseg.kunnr
    ,t3 as
    select a.budat,a.monat,b.vtweg,
    c.gjahr,c.buzei,c.shkzg,c.hkont, c.prctr,
    case when c.shkzg='S' then c.wrbtr*(-1)
    else c.wrbtr end as NTS,
    c.matnr,c.kunnr,
    c.menge*(-1) as Quantity
    from ldw_v1.BKPF a,ldw_v1.vbrk b, ldw_v1.bseg c
    where a.AWTYP='VBRK' and a.BLART='RV' and a.BUKRS='8431' and a.awkey=b.vbeln
    and a.bukrs=c.bukrs and a.belnr=c.belnr and a.gjahr=c.gjahr and c.koart='S'
    and c.ktosl is null and c.gsber='4466' and a.gjahr>='2011' and b.vtweg='01'
    ,trevenue as (
    select t3.budat,t3.monat,t3.vtweg, t3.gjahr,t3.hkont,t3.prctr,
    sum(t3.NTS) as NTS,t3.matnr,t3.kunnr,sum(t3.QUANTITY) as QUANTITY
    from t3
    group by t3.budat,t3.monat,t3.vtweg, t3.gjahr,t3.hkont,t3.prctr,t3.matnr,t3.kunnr
    select NVL(tr.budat,tc.budat) as budat,
    NVL(tr.monat,tc.monat) as monat,
    NVL(tr.vtweg,tc.vtweg) as vtweg,
    NVL(tr.gjahr, tc.gjahr) as gjahr,
    tr.hkont as NTS_hkont,
    tc.hkont as COGS_hkont,
    NVL(tr.prctr,tc.prctr) as prctr,
    NVL(tr.MATNR, tc.MATNR) as matnr,
    NVL(tr.kunnr, tc.kunnr) as kunnr,
    NVL(tr.Quantity, tc.Quantity) as Quantity,
    tr.NTS as NTS,
    tc.COGS as COGS
    from trevenue TR full outer join tcogs TC
    on TR.BUDAT=TC.BUDAT and TR.MONAT=TC.MONAT and TR.GJAHR=TC.GJAHR
    and TR.MATNR=TC.MATNR and TR.KUNNR=TC.KUNNR and TR.QUANTITY=TC.QUANTITY
    and TR.VTWEG=TC.VTWEG and TR.PRCTR=TC.PRCTR
    Edited by: user13566113 on 25.03.2011 5:26

    Without seeing what you tried it is hard to say what you did wrong, but this is how it would work
    SQL> create table t ( n number );
    Table created.
    SQL> insert into t
      2  with test_data as
      3    (select 1 x from dual union all
      4     select 2 x from dual union all
      5     select 3 x from dual union all
      6     select 4 x from dual)
      7  select x from test_data;
    4 rows created.
    SQL>

  • Need Help with inserting a screen shot

    Can someone pleassse help me?! If any of you are familiar with popular youtubers and how in their videos they include screen shots of facebook or twitter questions and they have them so they roll across the bottom  of the screen, can you please help me! If anyone knows how to do this in Imovie 11 it would be HUGELY appreciated! Because when i try the picture in picture settings it zooms the screen shot so its massive and its also not an oblong shape anymore (like the shape of a facebook reply) i also need help at how this would transition to roll in from one side of the screen to the other?!
    PLEASE HELP ME!!

    I think it is possible to do this in iMovie, although perhaps easier in Final Cut Pro X, which I would guess that iJustine is using.
    First, I would take a still image of my video at the points where I want to superimpose a graphic. Since she is mostly superimposing graphics on her talking head, a single still might be sufficient.
    For getting a still out of iMovie, see my User Tip here.
    https://discussions.apple.com/docs/DOC-3231
    Now, you will want to take this still to a photo editor that allows you to edit layers. Use PhotoShop if you have it. If you do not already have PhotoShop, it can be rather expensive, so I would suggest a tool like Acorn or Pixelmator, which I think are available in the Mac App Store.
    Create a project in the dimensions of your iMovie still, e.g. 1920x1080.
    You would put the still on the bottom layer, so you know where to put yoru graphics. You would position the graphic or screen grab at the next layer up. Now I would export the upper layer only as a PNG file. The PNG file has an Alpha Channel, which means you will see only the graphic and not the still in the background.
    The main thing Final Cut Pro would give you would be the easy ability to have multiple graphics on the screen at the same time.
    Now you can drag this PNG file into iMovie and drop it on the project clip where you want it to appear. A popup menu will appear. Choose Cutaway.
    There are probably other ways to do this, but that is the way I would do it.

  • Need help with inserting frame with scrolling images

    Hi,
        Im a beginner and need help putting a single box/frame with scrolling images in the middle of my layout, so that when viewed in browser, the header and footer remain in place, while the images and info in the frame in the centre of the page can be scrolled down/up?

    You can use an iframe element <iframe src="" width="" height="" scrolling="yes"> though if you're concerned with crawlers you should avoid frames as much as possible. 

  • Need help with integrating chat into Gui

    Hello Guys,
    I'm fairly new to Java and I have a quick question regarding a simple chat program in java. My problem is that I have a simple chat program that runs from its own JFrame etc. Most of you are probably familiar with the code below, i got it from one of my java books. In any case, what I'm attempting to do is integrate this chat pane into a gui that i have created. I attempted to call an instace of the Client class from my gui program so that I can use the textfield and textarea contained in my app, but it will not allow me to do it. Would I need to integrate this code into the code for my Gui class. I have a simple program that contains chat and a game. The code for the Client is listed below.
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.net.*;
    import javax.swing.*;
    public class Client
    extends JPanel {
    public static void main(String[] args) throws IOException {
    String name = args[0];
    String host = args[1];
    int port = Integer.parseInt(args[2]);
    final Socket s = new Socket(host, port);
    final Client c = new Client(name, s);
    JFrame f = new JFrame("Client : " + name);
    f.addWindowListener(new WindowAdapter() { 
    public void windowClosing(WindowEvent we) { 
    c.shutDown();
    System.exit(0);
    f.setSize(300, 300);
    f.setLocation(100, 100);
    f.setContentPane(c);
    f.setVisible(true);
    private String mName;
    private JTextArea mOutputArea;
    private JTextField mInputField;
    private PrintWriter mOut;
    public Client(final String name, Socket s)
    throws IOException {
    mName = name;
    createUI();
    wireNetwork(s);
    wireEvents();
    public void shutDown() {
    mOut.println("");
    mOut.close();
    protected void createUI() {
    setLayout(new BorderLayout());
    mOutputArea = new JTextArea();
    mOutputArea.setLineWrap(true);
    mOutputArea.setEditable(false);
    add(new JScrollPane(mOutputArea), BorderLayout.CENTER);
    mInputField = new JTextField(20);
    JPanel controls = new JPanel();
    controls.add(mInputField);
    add(controls, BorderLayout.SOUTH);
    mInputField.requestFocus();
    protected void wireNetwork(Socket s) throws IOException {
    mOut = new PrintWriter(s.getOutputStream(), true);
    final String eol = System.getProperty("line.separator");
    new Listener(s.getInputStream()) {
    public void processLine(String line) {
    mOutputArea.append(line + eol);
    mOutputArea.setCaretPosition(
    mOutputArea.getDocument().getLength());
    protected void wireEvents() {
    mInputField.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent ae) {
    String line = mInputField.getText();
    if (line.length() == 0) return;
    mOut.println(mName + " : " + line);
    mInputField.setText("");

    I think the easiest way to do it would be to cut an paste most of that code into your program. Then all you have to do is change some names so that it uses your textfield and textarea.

  • Need help with inserting 10MB CLOB

    Hi,
    I have an urgent issue and desperately need some help.
    There are several files on a FTP server that I need to insert their contents into a CLOB type column. One of the files has more than 10MB contents. What I've been doing is after connection is made to the FTP server, read in the contents in a file line by line into a String, then execute a SQL INSERT statement to insert a new record into the target table.
    +//.... make connection, read in files and parse into a String variable called fileContents+
    String psInsert = "Insert into FileTrack (Name, Contents) values";
    PreparedStatment ps = conn.prepareStatement(psInsert "(?,?)");+
    ps.setString(1, "some name");
    ps.setObject(2, fileContents);
    ps.executeUpdate();
    The above works fine for all other smaller files, except the 10MB one. The error I got was SQLCODE: -302, SQLSTATE: 22001, which is about not enough space issue. So I increased the CLOB column size and made sure it doesn't exceed the initial CLOB size setting and the database has plenty of space for storing this 10MB file. Still, I got the same error.
    Then I tried the following:
    ps.setObject(2, fileContents, java.sql.Types.CLOB);
    Failed with same error...
    Then I tried this:
    FileInputStream inputStream = new FileInputStream(fileContents);
    ps.setAsciiStream(2, inputStream, (int)()fileContents.length()));
    Still failed with the same error....
    Then I changed to ps.setCharStream()... still failed....
    What other options do I have to insert the 10MB contents? Can someone please help?
    Thanks heaps in advance!!

    we're still trying to upload that CLOB. Takes a while over this 2400bps modem ;)

  • Need Help with Photoshop elements 5.0

    I know that this is a very old version of photoshop elements, but I would still like to use it, since I paid $100.00 for it.  The problem is that it hasn't been installed onto my computer for awhile and now when I go to install it I get an error msg. each time. The msg is (C: Program Files\Adobe\EspionAlbum.dll. Verify that the file exist and that you can access it)!!
    I have gone to the program files and into adobe and the Espion file is there!  I have also called adobe technical support and they will not help me because it is such an outdated version.  I am really aggrivated with adobe support and would really appreciate any help that anyone might be able to offer!  Also, go slow, I am not a computer wiz, for sure!  Thank you!

    Okay...sorry...it is Windows XP Version 5.1  Does this clarify for everyone?  I assumed that most people would get that much once I saw that I left out the XP in the original post!
    Now that is out of the way...is it possible for anyone to help me with the problem at hand?  Can anyone tell me if I can run Elements 5.0 on Windows XP or are they not compatible?  If it should run, then please go back and read the original post so that you will see the issue that I am having!  Thanks so much!

  • I need help with Photoshop Elements 12

    I am taking an on-line class for digital scrapbooking.  I'm getting this error when trying to get the clip art for my project.  Please help me.  Is there a patch or update that I need.  When trying to update I get the following error.
    How long does it take to get support for these issues?

    Ok, but I still have no answer as to why my program is not working.  I am using my elements 12 for a on-line digital scrapebooking class.  I need this funcntion to work so I can do my homework and be able to move on with this class.
    Is there a patch or fix that I need?
    Angela

  • I need help with Premiere Elements 8

    I have enough rams and storage space. I am working in windows XP; I finished a project with still pictures, music, home movie clips, and title menu. I got the program to burn the first copy. I need 19 more, but the program keep "crashing". I have restarted, shut down and open the pc and program back up and nothing is working to keep it from crashing. Can anyone help me? Please!

    Hello LTDaniel (Lieutenant?),
      I am sorry to hear about this issue you are encountering, it must be frustrating.
      If you have not already done so, please check the troubleshooting steps documented in our knowledge base: 
    System errors and freezes | Burning DVDs, Blu-ray discs | Premiere Elements 8
      If you are not able to find a solution after trying these steps, please repost your inquiry on the Premiere Elements forum (this is the Photoshop Elements forum):
    http://forums.adobe.com/community/premiere_elements
    -Brett

  • Problems with inserting elements into vectors

    Hi,
    I have a problem with the setElementAt() method for vectors.
    I want to initialise a vector that is same size as a previous vector declared in my program and insert float 0.0 in all the positions.
    The code below is a for loop to do just this where count is the size of the previous vector.
    for(int i=0;i<count; i++)
                   vLargest.setElementAt(zero,i);
              }i have declared zero as a float
    float zero = 0.0f;
    the error that i'm getting is that it that the vector cannot be applied to a float.
    Can anybody tell me what i'm doing wrong?
    Thanks

    Yes you need to store Objects in your Vector not primitives.
    float is not an Object it is a primitive. But Float is an object.

  • I need help with Importing songs into Creative organizer please help!

    OK now i have a bunch of music files in my documents that all have MPEG4 with the itunes music symbol next to them. My problem is when i try to add them to my Windows media player nothing happens also when i search for the files in the Creative Import Wizard nothing shows up! Do i first need to put all the music i want on my ZVM im Windows Media Player first then add it's or is it something else? do i need to get rid of itunes entirely and just have the music files in my documents? Im really really confused please help!!!!!! Also No tracks show up when i try to add them to Windows Media Player or Creative MediaSource5 even though when i know i put them there
    P.S. What do u guys do ( I mean people with Zen Vison M's) Any know of any guides too? that would be great!Message Edited by Chrismic3 on 03-9-200705:54 PM
    Message Edited by Chrismic3 on 03-9-200706:00 PM

    bump

  • I need help with Photoshop Elements 8

    I just downloaded Photoshop Element 8 to try as a trail.   I can get the organizer working but when I go to edit a photo with full edit I get an error message that says Photoshop editors as stopped working and I then need to shut down the program using  thh task manager.. how can I resolve this problem

    Unfortunately, there are many reasons why the PSE Editor might crash, and often it is hard to diagnose quickly the reason for the crash.   Here are some steps you can take to try to fix the problem:
    http://www.johnrellis.com/psedbtool/photoshop-elements-faq.htm#_Troubleshooting_Editor_cra shes

  • Help with inserting pages into a PDF form

    Hi everyone,
    I used LiveCycle Designer ES for the first time to make a fillable PDF form.  The form works splendidly, but the users wish to insert PDF pages to the end of the form before submitting (using Acrobat).
    I can't figure out how to allow this to happen.
    I open the form I made in Acrobat 9.0 and the Insert Pages tab is greyed out.
    I went back to LC and set form options to "Allow all changs except extract" and this seems to have done nothing.
    When I look at the security settings in Adobe and click on Permissions Details, I see two different things.  In Docmuent Security, the security method is set as Password Security and if I open Show Details It says changing the Document is allowed.
    But in the Document Restrictions Summary, changing the Document is set at Not allowed.
    Probably a newbie question, but I am stumped.
    Thanks,
    Becky

    Hey there,
    If you've created a dynamic form, then the PDF document is no loger an acroform, it's an XFA form. I might be wrong, but I'm fairly certain that XFA forms can't have their pages extracted or have pages added via Acrobat.
    If that is the case (I'm fairly certain it is) then you have a few options:
    1) Redesign the form in Acrobat, losing the dynamic functionality.
    2) Create the form in Livecycle, and include the hidden subform that is shown on submit or button press (this would require you to know what the users want added, it would also require that the thing they're adding is always the same)
    3) Install a virtual printer, get them to fill out the dynamic form, then 'print' the via the dynamic printer.
    Personally, I'd go with option 3. A virtual printer is a program that prints the current document to a file, instead of an actual printer. 'Cute PDF Writer' is a virtual printer that is able to 'print' any document to a new pdf document. The new form will not be dynamic, and the fields are made read-only (hense why they should fill it out before printing it), but you will be able to insert pages.
    If you would like feel free to send me a message with any questions regarding cutepdf writer.
    - Scott
    P.S. CutePDF Writer also has the advantage of being free, well-supported, and just plain awesome. =P I would suggest getting it, even if you don't need it to resolve this issue. I use it all the time.

  • Need help with moving files into Itunes and syncing

    Please help.
    I have an external hard drive with my music on it.  I created a new playlist in Itunes and did a drag and drop from my external hard drive into my newly created playlist. 
    Now that I go back and play the items I brought over, I get an error that says "original files not found" and it won't play and therefore does not seem to be syncing to the Ipod to be able to play.
    Can you please give me guidance as to what I can do without recreating all the work I had already done?
    Thanks,
    Michelle

    Is the external drive connected?
    Has the drive letter possibly changed due to being disconnected and reconnected?

Maybe you are looking for

  • Open Sales Order Quantity

    Hi, Does anyone know what table & field is the open sales order quantity stored? Thanks.

  • Toshiba Satellite C655 SP4168M freezes while playing a game

    So i've been having problems with mi laptop very recently with a game i'm playing (League of legends), the game normally works perfectly, but at random times it just completely freezes (making an awkward sttutering sound) and i have to forcefully shu

  • Problem with opening Adobe Photoshop

    Hi I am having a problem opening Adobe Photoshop. I use Adobe Photoshop CS6 on my pc. The problem is I open up Adobe Photoshop CS6 and a window come's up and is asking me to pay $29.99. And I already paid for a 1 year membership already. And now Adob

  • MBPro wont shut down

    Since the mtn lion update I am unable to shut down my laptop.  Screen goes white with spnning circle.  Have to hold the power button down in order for it to actually turn off. I've ran the check disk utility a few times with no luck...actually I take

  • Collapsing Folders

    I have set up my iPad to work with Microsoft Exchange e-mail, however I have a large number of folders. The iPad does not seem to allow me to collapse these folders. Instead I need to scroll through them all. Does anyone have a solution to this?