Results 1 to 5 of 5

Thread: Problem in <Shape> List

  1. #1
    Join Date
    Dec 2009
    Posts
    211

    Problem in <Shape> List

    Hello,
    I have a class that derives from JPanel where we draw the curve Graph, I have inserted a private attribute
    Code:
    Public Class Gra{ ....
    private List <Shape> shapes;
    ...}
    And
    Code:
    sh = new ArrayList <Shape>(); / / Collection form used to break
    But this is not working for me, If you have any solution for this then please do post back. Thanks in advance.

  2. #2
    Join Date
    Apr 2008
    Posts
    264

    Re: Problem in <Shape> List

    Hello,
    I am new to java, but I have done a program, keeping your needs in mind. Just check out the code and see if this works with you.
    Code:
    Public View Point(){ .....
    if(ok){
    g.drawLine(num-1+ x, tab_coor[indiceTab -(int)not][i][0], num + x, tab_coor[indiceTab][i][0]);
    shapes.add(new Line2D.Double(num-1+ x, tab_coor[indiceTab -(int)not][i][0], num + x, tab_coor[indiceTab][i][0]));
    }
    ....
    if(ok){
    {g.drawLine(num-1+ x, tab_coor[indiceTab -(int)not][i][c], num + x, tab_coor[indiceTab][i][c]);
    shapes.add(new Line2D.Double(num-1+ x, tab_coor[indiceTab -(int)not][i][c], num + x, tab_coor[indiceTab][i][c]));
    }
    }

  3. #3
    Join Date
    Nov 2009
    Posts
    335

    Re: Problem in <Shape> List

    Hello,
    I think if you need you can use the following methods in your code.
    Code:
    a.getfenfraph ()
    a.getfenfraph (). getGraphePh ()
    Simply add System.out to determine which is the standard output you want in your code. If you have any more problem regarding this topic then please do post back and we will try to solve it.

  4. #4
    Join Date
    Nov 2009
    Posts
    446

    Re: Problem in <Shape> List

    Hello,
    Yes, I agree with the above posted, you can do it.
    Here is an sample example
    Code:
    System.out.System.out.println( a);
    System.out.System.out.println( a.getfenfraph());
    System.out.System.out.println( a.getfenfraph().getGraphePh());
    sh = a.getfenfraph().getGraphePh().getmesShapes();
    It does not fix the bug But it will know which element is null. Hope this method will help you in your code.

  5. #5
    Join Date
    Nov 2009
    Posts
    347

    Re: Problem in <Shape> List

    Hello,
    Uncomment this line to your constructor, you have done a mistake there, this may cause a problem when you are trying to compile the program or you can get an undesired the results
    Code:
    / / List <Shape>sh <Shape> = new ArrayList ();
    In fact your list is initialized at any time, hence the NullPointerException that you get. I guess you will correct is soon.

Similar Threads

  1. Cursor Shape And Size
    By hatred in forum Windows XP Support
    Replies: 3
    Last Post: 26-09-2011, 07:20 PM
  2. Shape interface of java
    By Gajananvihari in forum Software Development
    Replies: 4
    Last Post: 09-03-2010, 05:08 PM
  3. Changing the Cursor shape in Java
    By rashmi_ay in forum Software Development
    Replies: 4
    Last Post: 30-11-2009, 10:58 AM
  4. How to draw outline of a shape in photoshop?
    By sizzla in forum Windows Software
    Replies: 2
    Last Post: 17-06-2009, 12:23 PM
  5. Multi Shape Cobra Stand for PSP
    By Alexxx in forum Portable Devices
    Replies: 3
    Last Post: 26-03-2009, 11:10 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,267,269.49226 seconds with 17 queries