April 17th, 2011, 04:34 PM
No matter what I change, program still runs what it said before...
OK... I need to change the button and my name to CENTER, the input to NORTH, and the green blocks to SOUTH. I did that.... but for some reason it keeps running the way I had it before... also if I change any text, it won't show up as different when I compile and run... for example if I changed the "Name: " label to "Happy: " then compile and run, it still says "Name: "
By the way, there is an external method, but it doesn't have anything to do with what I'm changing. I colored the areas I need to change... they are oriented the way I need them, but see how the program runs in the attached .jpg
This is due tonight... please somebody tell me what's wrong so I can fix it!
Chapter 5: Reserve a Party Room
Programmer: Ben Brotsker
Purpose: This program creats a windowed application to reserve a part room.
It calls an external class named Rooms. The frames are repositioned.
public class ReservationsRepositioned extends Frame implements ActionListener
Color lightRed = new Color(255, 90, 90);
Color lightGreen = new Color(140, 215, 40);
Rooms room = new Rooms(5,3);
Panel roomPanel = new Panel();
TextArea roomDisplay = new TextArea;
Panel buttonPanel = new Panel();
Button bookButton = new Button("Book Room");
Label nameLabel = new Label("Ben B******* 04/16/11");
Panel inputPanel = new Panel();
Label custNameLabel = new Label("Name:");
TextField nameField = new TextField(15);
Label custPhoneLabel = new Label("Phone number:");
TextField phoneField = new TextField(15);
Label numLabel = new Label("SOMETHING IS WRONG!!!:");
Choice numberOfGuests = new Choice();
CheckboxGroup options = new CheckboxGroup();
Checkbox nonSmoking = new Checkbox("Nonsmoking",false,options);
Checkbox smoking = new Checkbox("Smoking",false,options);
Checkbox hidden = new Checkbox("",true,options);
//set Layouts for frame and three panels
//add components to room pane
for (int i=1; i<9; i++)
roomDisplay[i] = new TextArea(null,3,5,3);
roomDisplay[i].setText("Room " + i + " Nonsmoking");
roomDisplay[i].setText("Room " + i + " Smoking");
//add components to button panel
//add compoents to input panel
for(int i=8; i<=20; i++)
//add panels to frame
//overriding the windowClosing() method will allow the user to click the close
public void windowClosing(WindowEvent e)
} //end of constructor method
public static void main(String args)
Reservations f = new Reservations();
f.setTitle("Reserve a Party Room");
} //end of main
public void actionPerformed(ActionEvent e)
JOptionPane.showMessageDialog(null,"You must select Nonsmoking or Smoking.","Error",JOptionPane.ERROR_MESSAGE);
int available = room.bookRoom(smoking.getState());
if(available > 0) //room is available
roomDisplay[available].setBackground(lightRed); //display room as occupied
roomDisplay[available].getText() + "\n" +
nameField.getText() + " " +
phoneField.getText() + "\nparty of " +
); //display info in room
else //room is not available
JOptionPane.showMessageDialog(null, "Smoking is full.","Error", +
JOptionPane.showMessageDialog(null, "Nonsmoking is full.","Error", +
} //end of else blaock that checks the available room number
} //end of else block that checks the state of the hidden option button
} //end of actionPerformed() method
//reset the text fields and choice component
} //end of clearFields method
} //end of Reservations class
Last edited by LogicWavelength; April 17th, 2011 at 04:37 PM.
April 18th, 2011, 04:26 AM
Re: No matter what I change, program still runs what it said before...
Probably too late for you, but the class you posted is called ReservationsRepositioned but the main(..) method is creating an instance of Reservations, which I guess is the original class...
Experience is a poor teacher: it gives its tests before it teaches its lessons...
Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.