pete stein wrote:You need to post the class with the Vector code in it, the class that is giving you the error. Perhaps it's my mistake, but I don't see it. Also, you have a JPanel named rooms, and is this perchance clashing with the Vector variable?
Ross McManus wrote:
Sorry about that the code that has the Vector in it is the GUI class I just took it out to post this and posted the vector code below it.
Ross McManus wrote:Thanks for the reply I have done what you said and got it compiling now.
I am just not sure if it is adding the JLabels to a vector or am I just adding random numbers and text?
I am not 100% sure how to do this.
Also I have MeetingRooms so how would I add them instead of it being Bedroom would I need to create a new Vector for MeetingRooms?
pete stein wrote:
Ross McManus wrote:Thanks for the reply I have done what you said and got it compiling now.
OK, now that we've got the compile issue out of the way, let's consider logic. Can you tell us why you want to add JLabels to a Vector? Usually when I do something of this sort, I add a data object, such as in this example a Room object, to the Vector (or an ArrayList which I prefer to use), not a GUI component. Then the GUI uses this Vector or List to help build the GUI components. Can you tell us more of your design?
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Ross McManus wrote:
I want to add the JLabels to a Vector because in the Assignment sheet I have on the GUI section it states
"The rooms that are created should be added to Vector of Rooms, to be used when processing events."
I thought that it would be the JLabels that I had to add to the vector because before that part it tells me that
"Hotel GUI is to have internal panels holding 5 JButtons and JLabels. Each JLabel represents a room and is to display text giving the room number and type of room(single, double or meeting room)
So that is where I thought I would have to add a Vector of JLabels.
Later on for the Mouse Events section it tells me
"If the source of a button event is 'BOOK SINGLE ROOM' or 'BOOK DOUBLE ROOM' the Vector of Rooms should be searched over the range for bedrooms, to ensure that there is a vacant room of the requested type: otherwise a suitable message is displayed stating there are no rooms available"
Or do I have to create Room objects for each room and thats what needs to be in the vector?
Ross McManus wrote:Actually looking at my classes again.
The MeetingRoom class does not have another constructor to create a Room object in.
I am confused. Do I just create all the Room objects in the Room() constructor the Bedroom's & MeetingRooms.
Ross McManus wrote:Okay I think I get it now.
I create all the Room objects and the Bedroom's & Meetingroom's are just types of Room.
So I think this is right what I have done. It compiles.
Ross McManus wrote:So would I need to create the Room objects etc Room = room201 new Room();
At the beginning of the GUI class? Then the vector underneath then obviously the rest.
I have uploaded the assignment pdf to a filehosting site here http://www.mediafire.com/?g6iihien506hccx as I did not know how else to post the assingment
Ross McManus wrote:
Thanks for the reply.
So it would be something like