Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Fill seatpanel

  1. #1
    Junior Member
    Join Date
    Jun 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Fill seatpanel

    Hello all.

    Im a bit lost and all out of ideas on how to solve my problem:
    A lil background:
    im filling a ShowPanel with different shows being given in a theatre (connected to DAO classes, that in their turn get values out of a database) , and then when you choose from this you get several dates. Then when you click a date, the seatings appear in the SeatPanel.

    I got the first part with the shows and dates. But Im stuck at getting the seatings.
    I have a controller class which calls the shows+dates (this happens in one method). But i always get a nullpointerexception for the seatings. (this happens in a different method).

    I think i just don't know how to link the chosen show+date with the seatings.
    For the moment i have :

    public ArrayList<Seats> getSeating() throws SeatingException{
        ArrayList<Place> seating = new ArrayList<Place>();
        PlaceDAO pdao = PlaceDAO.getInstance();
        try{
            for (Show s : show ) {
           ArrayList<Showdate> showdate =  s.getDates();
     
     
        for (Showdate sd : showdate ){
             seating.addAll(pdao.getSeating(sd));
     
        }
        }
    }
        catch (SeatingException e) {
            JOptionPane.showMessageDialog(null,  e.getMessage(),"No seatings found",
                JOptionPane.ERROR_MESSAGE);
            e.printStackTrace();
        }
     
        return seating;
      }

    The code to get the shows and dates is the following :

    public ArrayList<Show> getShows() throws ShowException {
     
        try{   
        ShowDAO sdao = ShowDAO.getInstance();
        show= sdao.getShows();
     
        }
        catch (ShowException e) {
          JOptionPane.showMessageDialog(null,  e.getMessage(),"No shows found",
              JOptionPane.ERROR_MESSAGE);
          e.printStackTrace();
        }
        return show;
      }
    So this part works..

    The given class PlaceDao has a static getInstance() method and an ArrayList<model.Place> getSeating(model.Showdate showdate) method.

    In the next stage i have to try and fill the panel with the seatings, but first i need to be able to call them.

    Please help me, i need it.

    the NullPointerException points to :
    seating.addAll(pdao.getSeating(sd));

    but this can't be. The pdao. is definitely filled with values
    so why isn't it responding ?


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,067
    Thanks
    47
    Thanked 2,146 Times in 2,119 Posts

    Default Re: Fill seatpanel

    the NullPointerException points to :
    seating.addAll(pdao.getSeating(sd));
    If pdao is not nulll, what about seating, sd and the value returned by getSeating()?
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Jun 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Fill seatpanel

    well, you can correct if im wrong. Because i obviously dont fully comprehend :

    i believe seating is not null because it's initiated as an arrayList, and the filled with the seating values of a given showdate

    some shows don't have showdates, this is true
    but i can't look into this information because these are given DAO classes, which i cannot alter


    so there has to be a way to get the seatings of the shows that have showdates
    but i just don't know how anymore

    i've been trying for several days, and i simply do not see it

    it might be very obvious, but i do not see it

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,067
    Thanks
    47
    Thanked 2,146 Times in 2,119 Posts

    Default Re: Fill seatpanel

    What value did the getSeating() method return?

    --- Update ---

    Also posted at: Fill a seatpanel
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Fill
    By bejoykodiyan in forum What's Wrong With My Code?
    Replies: 2
    Last Post: July 9th, 2012, 02:28 AM
  2. Text fill
    By IBANGS in forum JDBC & Databases
    Replies: 1
    Last Post: May 26th, 2010, 03:42 AM
  3. Auto Fill the TextField
    By malladiG in forum Java Theory & Questions
    Replies: 0
    Last Post: April 6th, 2010, 07:32 AM
  4. Fill array concurrently
    By mamba in forum Collections and Generics
    Replies: 2
    Last Post: October 15th, 2009, 07:08 PM
  5. How do I fix my program so I can use the keyboard to type in the numbers?
    By rocafella5007 in forum File I/O & Other I/O Streams
    Replies: 1
    Last Post: April 29th, 2009, 02:39 PM