Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-08-2013, 10:02 AM   PM User | #1
angel06
New to the CF scene

 
Join Date: Feb 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
angel06 is an unknown quantity at this point
Problem with simple ordering system

Hello! I'm currently fixing this program it is a simple ordering system and now I am stuck with the error it displays specifically in the line: GridBagConstraints.RELATIVE; the complete code is below I hope you guys can help me


class OrderEntryFrameType extends Frame {

OrderEntryFrameType (String InTitle) {
super(InTitle);

}

WarningDialog WDialog = new WarningDialog
(this, "You have not entered a name. ");
public void setup() {

// Set the initial grid bag layout for the frame.
GridBagLayout PrimaryLayout = new GridBagLayout();
setLayout(PrimaryLayout);

// Set the constraints for the Product Panel, which will contain product
// choices, sizes, etc.
GridBagConstraints ProductPanelConstraints = new GridBagConstraints();

// The Product Panel will take up the rest of the space on this line.
ProductPanelConstraints.gridwidth = GridBagConstraints.REMAINDER;

// Declare and initialize the Product Panel.
Panel ProductPanel = new Panel();

// Set the layout for the Product Panel and set the constraints for
// the components inside of the Product Panel.
GridBagLayout ProductPanelLayout = new GridBagLayout();
GridBagConstraints InProductPanelConstraints =
new GridBagConstraints();
ProductPanel.setLayout(ProductPanelLayout);

// Here we will set the list panel, which will hold the
// list choice method and insertion.
Panel ListPanel = new Panel();
ListPanel.setLayout(new BorderLayout());

Label ProductLabel = new Label("Products");
ListPanel.add("North", ProductLabel);

// Create the list, 4 items visible, no multiple
// selections.
ProductList = new List(4, false);

// Add items to the List.
ProductList.addItem("Oscar");
ProductList.addItem("Lionhead");
ProductList.addItem("Jack Dempsey");
ProductList.addItem("Angelfish");

// Add the List to the list panel.
ListPanel.add("Center",ProductList);

// Add the embedded panel to the Product Panel.
InProductPanelConstraints.anchor = GridBagConstraints.NORTH;
ProductPanelLayout.setConstraints(
ListPanel, InProductPanelConstraints);
ProductPanel.add(ListPanel);

// Another panel which will be embedded in the Product Panel.
Panel SizePanel = new Panel();
SizePanel.setLayout(new BorderLayout());


// Add a label to the choice of sizes.
SizePanel.add("North", new Label("Size:"));

// Create the Choice box.
SizeChoice = new Choice();

// Add items to the List.
SizeChoice.addItem("Jumbo");
SizeChoice.addItem("Large");
SizeChoice.addItem("Medium");
SizeChoice.addItem("Small");

// Add the Choice to the Applet panel.
SizePanel.add("Center",SizeChoice);

// Add the embedded panel to the Product Panel.
ProductPanelLayout.setConstraints(SizePanel,
InProductPanelConstraints);
ProductPanel.add(SizePanel);

// Another panel which will be embedded in the Product Panel.
Panel AmountPanel = new Panel();
AmountPanel.setLayout(new BorderLayout());

// Add a label to the slider.
AmountPanel.add("North", new Label("Amount:"));

// Another embedded panel which will contain the slider and
// the output label.
Panel SliderPanel = new Panel();
SliderPanel.setLayout(new FlowLayout());

// Insert the label which says how many are set
// to be ordered of the item.
SliderPanel.add(AmountLabel);

// Create a vertical slider, initial value of 0,
// minimum value of 0, maximum value of 144.
OrderAmountSlider = new
Scrollbar(Scrollbar.HORIZONTAL, 0, 0, 0, 144);
// Insert the slider to the Applet panel.
SliderPanel.add(OrderAmountSlider);

AmountPanel.add("Center", SliderPanel);

// Add the embedded panel to the Product Panel.
ProductPanelLayout.setConstraints(AmountPanel,
InProductPanelConstraints);
ProductPanel.add(AmountPanel);

// The last panel which will be embedded in the Product Panel.
Panel TotalPanel = new Panel();
TotalPanel.setLayout(new BorderLayout());

// Add the subtotal label and a label saying
// that it is the subtotal.
TotalPanel.add("North", new Label("Total: "));
TotalPanel.add("South",TotalLabel);

ProductPanelLayout.setConstraints(TotalPanel,
InProductPanelConstraints);
ProductPanel.add(TotalPanel);

ProductPanelLayout.setConstraints(TotalPanel,
InProductPanelConstraints);
// Add the embedded panel to the Product Panel.
ProductPanel.add(TotalPanel);

// Set the constraints for the Product Panel's insertion.
PrimaryLayout.setConstraints(ProductPanel, ProductPanelConstraints);
// Add the Product Panel to the frame.
add(ProductPanel);

// The second panel to be embedded in the frame is the Info panel.
// This panel gets the information about the user.
GridBagLayout InfoPanelLayout = new GridBagLayout();
Panel InfoPanel = new Panel();
GridBagConstraints InfoPanelConstraints = new GridBagConstraints();
InfoPanelConstraints.gridwidth = GridBagConstraints.REMAINDER;
ProductPanelLayout.setConstraints(InfoPanel, InfoPanelConstraints);
InfoPanel.setLayout(InfoPanelLayout);

GridBagConstraints InInfoConstraints = new GridBagConstraints();
InInfoConstraints.gridwidth = GridBagConstraints.REMAINDER;
InInfoConstraints.anchor = GridBagConstraints.WEST;
Label InfoLabel = new Label("Your information: ");
InfoPanelLayout.setConstraints(InfoLabel, InInfoConstraints);
InfoPanel.add(InfoLabel);

// The name entry field area.
Panel NameFieldPanel = new Panel();
NameFieldPanel.setLayout(new BorderLayout());
NameFieldPanel.add("West",new Label("Name:"));
NameFieldPanel.add("East",NameEntryField);
InInfoConstraints.anchor = GridBagConstraints.EAST;
InfoPanelLayout.setConstraints(NameFieldPanel,
InInfoConstraints);
InfoPanel.add(NameFieldPanel);

// The Street entry area implementation.
Panel StreetFieldPanel = new Panel();
StreetFieldPanel.setLayout(new BorderLayout());
StreetFieldPanel.add("West",new Label("Street:"));
StreetFieldPanel.add("East",StreetEntryField);

InfoPanelLayout.setConstraints(StreetFieldPanel,
InInfoConstraints);
InfoPanel.add(StreetFieldPanel);

Panel CityFieldPanel = new Panel();
CityFieldPanel.setLayout(new BorderLayout());
CityFieldPanel.add("West",new Label("City:"));
EntryFieldPanel.add("East",CityEntryField);
InfoPanelLayout.setConstraints(CityFieldPanel,
InInfoConstraints);
InfoPanel.add(CityFieldPanel);

// The zip entry field implementation.
Panel ZipFieldPanel = new Panel();
ZipFieldPanel.setLayout(new BorderLayout());
ZipFieldPanel.add("West",new Label("Zip:"));
ZipFieldPanel.add("East",ZipEntryField);
InfoPanelLayout.setConstraints(ZipFieldPanel,
InInfoConstraints);
InfoPanel.add(ZipFieldPanel);

// The comment label.
InInfoConstraints.anchor = GridBagConstraints.WEST;
Label CommentLabel = new Label("Comments: ");
InfoPanelLayout.setConstraints(CommentLabel,
InInfoConstraints);
InfoPanel.add(CommentLabel);

// Add the comment box.
InInfoConstraints.anchor = GridBagConstraints.CENTER;
InfoPanelLayout.setConstraints(CommentTextArea,
InInfoConstraints);
InfoPanel.add(CommentTextArea);

PrimaryLayout.setConstraints(InfoPanel, InfoPanelConstraints);
// Add the info panel to the frame layout.
add(InfoPanel);


// Add and create the repeat customer checkbox.
Panel ContactPanel = new Panel();
ContactPanel.setLayout(new BorderLayout());

// Add a label to the ContactMethodGroup.
ContactPanel.add("North",new
Label("How would you like to be contacted? "));

// Declare the CheckboxGroup, and allocate space.
CheckboxGroup ContactMethodGroup;
ContactMethodGroup = new CheckboxGroup();

// Create some checkboxes to put in the group.
Checkbox EmailBox = new Checkbox("Email",ContactMethodGroup,true);
Checkbox PhoneBox = new
Checkbox("Phone",ContactMethodGroup,false);
Checkbox MailBox = new
Checkbox("US Mail",ContactMethodGroup,false);

// Add the checkboxes into the applet panel.
ContactPanel.add("West",EmailBox);
ContactPanel.add("Center",PhoneBox);
ContactPanel.add("East",MailBox);

// Sets the constraints for the Contact panel.
GridBagConstraints ContactPanelConstraints = new GridBagConstraints();
ContactPanelConstraints.gridwidth = 2;
GridBagConstraints.RELATIVE;
ContactPanelConstraints.weightx = 2.0;
PrimaryLayout.setConstraints(ContactPanel, ContactPanelConstraints);
add(ContactPanel);

// Insert the different checkboxes into the panel.
GridBagConstraints CustCheckBoxConstraints = new GridBagConstraints();
CustCheckBoxConstraints.weightx =1.0;
CustCheckBoxConstraints.gridwidth = GridBagConstraints.REMAINDER;
Checkbox RepeatCustCheckBox = new Checkbox("Repeat Customer?");
PrimaryLayout.setConstraints(RepeatCustCheckBox, CustCheckBoxConstraints);
add(RepeatCustCheckBox);

GridBagConstraints ButtonConstraints = new GridBagConstraints();
ButtonConstraints.gridx = GridBagConstraints.RELATIVE;

// Spreads the buttons out across the window.
ButtonConstraints.weightx = 1.0;
ButtonConstraints.weighty = 1.0;

// Declare, set, and add the "Submit" button.
SubmitButton = new Button("Submit");
PrimaryLayout.setConstraints(SubmitButton, ButtonConstraints);
add(SubmitButton);

// Declare, set, and add the "Clear" button.
ClearButton = new Button("Clear");
PrimaryLayout.setConstraints(ClearButton, ButtonConstraints);
add(ClearButton);

// Set the constraints and insert the Quit button. This button
// due to the REMAINDER setting will be the last on the line.
GridBagConstraints LastButtonConstraints = new GridBagConstraints();
LastButtonConstraints.gridwidth = GridBagConstraints.REMAINDER;
QuitButton = new Button("Quit");
PrimaryLayout.setConstraints(QuitButton, LastButtonConstraints);
add(QuitButton);

// Method which resets all of the internal values.
resetValues();
}
angel06 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:02 AM.


Advertisement
Log in to turn off these ads.