Job4Suprmn
asked on
Can anyone see why my formatting is going crazy...
My code is below. I'm sure the program is right and everything is in its containers. It's just that my JComboBox's aren't showing up correctly...they appear all stretched out and I can't seem to fix it. Is there a way to keep them a certain size? Need help ASAP. I know the program is long, I'm sorry! Maybe copy/paste it into JBuilder.
Thanks,
Erica
package Project5;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.text.*;
import javax.swing.JOptionPane;
import javax.swing.JTextArea;
import java.text.NumberFormat;
public class Project5 {
public static String output = ("");
public static void main(String[] args) {
// Declare GUI Components and Variables
JLabel JLTitle,
JLName,
JLAddress,
JLCity,
JLPhone,
JLEmail,
JLCookies,
JLThinMints,
JLCarDelight,
JLShortBread,
JLPBPatties,
JLPBSandwich,
JLLemonPastry,
JLDeliverDate,
JLDeliverTime,
JLJoinSupportGS,
JLReminder,
JLStatement;
final JTextField JTFName,
JTFAddress,
JTFCity,
JTFPhone,
JTFEmail;
JButton JBSubmit,
JBClear;
final JComboBox JComBoxThinMints,
JComBoxCarDelight,
JComBoxShortBread,
JComBoxPBPatties,
JComBoxPBSandwich,
JComBoxLemonPastry,
JComBoxDeliverDate;
final JRadioButton JRBDTTwelveTwo,
JRBDTTwoFour,
JRBDTFourSix,
JRBDTSixEight;
final JCheckBox JCBJoinSupportGS,
JCBReminder;
JPanel Panel,
CustomerPanel,
ButtonsPanel,
NamePanel,
AddressPanel,
CityPanel,
PhonePanel,
EmailPanel,
SelectPanel,
CookiePanel,
ThinMintsPanel,
CarDelightPanel,
ShortBreadPanel,
PBPattiesPanel,
PBSandwichPanel,
LemonPastryPanel,
DeliverDatePanel,
DeliverTimePanel,
RadioButtonPanel,
JoinSupportPanel,
ReminderPanel,
TitlePanel;
Icon GSLogo,
Cookies;
// Assign Text to JLabels
JLTitle = new JLabel("Girl Scout Cookie Order Form");
Color GSGreen = new Color (27,152,14);
JLTitle.setForeground(GSGr een);
Font TitleFont = new Font("Courier",Font.BOLD,2 6);
JLTitle.setFont(TitleFont) ;
JLName = new JLabel("Name: ");
JLAddress = new JLabel("Street Address: ");
JLCity = new JLabel("City: ");
JLPhone = new JLabel("Phone Number: ");
JLEmail = new JLabel("E-mail Address: ");
JLCookies = new JLabel("Select How Many Boxes You Would Like: ");
JLThinMints = new JLabel("Thin Mints ");
JLCarDelight = new JLabel("Caramel Delights ");
JLShortBread = new JLabel("Short Bread ");
JLPBPatties = new JLabel("Peanut Butter Patties ");
JLPBSandwich = new JLabel("Peanut Butter Sandwiches ");
JLLemonPastry = new JLabel("Lemon Pastry ");
JLDeliverDate = new JLabel("Preferred Delivery Date: ");
JLDeliverTime = new JLabel("Preferred Delivery Time: ");
JLJoinSupportGS = new JLabel("");
JLReminder = new JLabel("");
JLStatement = new JLabel("Money will be collected when cookies are delivered. Thank you for supporting your local Girl Scouts.");
// Assign Lengths to Text Fields
JTFName = new JTextField(15);
JTFAddress = new JTextField(25);
JTFCity = new JTextField(15);
JTFPhone = new JTextField(15);
JTFEmail = new JTextField(15);
// Assign Text to Buttons
JBClear = new JButton("Clear");
JBSubmit = new JButton("Sumit");
// Array of Numbers for JComboBox
String[] numCookies = {
"0","1","2","3","4","5","6 ","7","8", "9","10"," 11","12"," 13","14",
"15","16","17","18","19"," 20","21"," 22","23"," 24","25"};
// Array of Delivery Dates for JComBoxDeliverDate
String[] deliverDates = {"Sunday","Monday","Tuesda y","Wednes day","Thur sday","Fri day","Satu rday"};
// Assign Contents to JComboBoxes
JComBoxThinMints = new JComboBox(numCookies);
JComBoxThinMints.setBackgr ound(Color .white);
JComBoxCarDelight = new JComboBox(numCookies);
JComBoxCarDelight.setBackg round(Colo r.white);
JComBoxShortBread = new JComboBox(numCookies);
JComBoxShortBread.setBackg round(Colo r.white);
JComBoxPBPatties = new JComboBox(numCookies);
JComBoxPBPatties.setBackgr ound(Color .white);
JComBoxPBSandwich = new JComboBox(numCookies);
JComBoxPBSandwich.setBackg round(Colo r.white);
JComBoxLemonPastry = new JComboBox(numCookies);
JComBoxLemonPastry.setBack ground(Col or.white);
JComBoxDeliverDate = new JComboBox(deliverDates);
JComBoxDeliverDate.setBack ground(Col or.white);
// Assign Functionality and Text to Radio Buttons
JRBDTTwelveTwo = new JRadioButton("12:00-2:00", true);
JRBDTTwelveTwo.setBackgrou nd(Color.w hite);
JRBDTTwoFour = new JRadioButton("2:00-4:00",f alse);
JRBDTTwoFour.setBackground (Color.whi te);
JRBDTFourSix = new JRadioButton("4:00-6:00",f alse);
JRBDTFourSix.setBackground (Color.whi te);
JRBDTSixEight = new JRadioButton("6:00-8:00",f alse);
JRBDTSixEight.setBackgroun d(Color.wh ite);
ButtonGroup deliverTime = new ButtonGroup();
deliverTime.add(JRBDTTwelv eTwo);
deliverTime.add(JRBDTTwoFo ur);
deliverTime.add(JRBDTFourS ix);
deliverTime.add(JRBDTSixEi ght);
// Assign Functionality and Text to Check Boxes
JCBJoinSupportGS = new JCheckBox(" E-mail me about how to join/support Girl Scouts",false);
JCBJoinSupportGS.setBackgr ound(Color .white);
JCBReminder = new JCheckBox(" E-mail me/call me to remind me the day before delivery",false);
JCBReminder.setBackground( Color.whit e);
// Create Panels
Panel = new JPanel();
Panel.setBackground(Color. white);
CustomerPanel = new JPanel();
CustomerPanel.setBackgroun d(Color.wh ite);
ButtonsPanel = new JPanel();
ButtonsPanel.setBackground (Color.whi te);
NamePanel = new JPanel();
NamePanel.setBackground(Co lor.white) ;
AddressPanel = new JPanel();
AddressPanel.setBackground (Color.whi te);
CityPanel = new JPanel();
CityPanel.setBackground(Co lor.white) ;
PhonePanel = new JPanel();
PhonePanel.setBackground(C olor.white );
EmailPanel = new JPanel();
EmailPanel.setBackground(C olor.white );
CookiePanel = new JPanel();
CookiePanel.setBackground( Color.whit e);
SelectPanel = new JPanel();
SelectPanel.setBackground( Color.whit e);
ThinMintsPanel = new JPanel();
ThinMintsPanel.setBackgrou nd(Color.w hite);
CarDelightPanel = new JPanel();
CarDelightPanel.setBackgro und(Color. white);
ShortBreadPanel = new JPanel();
ShortBreadPanel.setBackgro und(Color. white);
PBPattiesPanel = new JPanel();
PBPattiesPanel.setBackgrou nd(Color.w hite);
PBSandwichPanel = new JPanel();
PBSandwichPanel.setBackgro und(Color. white);
LemonPastryPanel = new JPanel();
LemonPastryPanel.setBackgr ound(Color .white);
DeliverDatePanel = new JPanel();
DeliverDatePanel.setBackgr ound(Color .white);
DeliverTimePanel = new JPanel();
DeliverTimePanel.setBackgr ound(Color .white);
RadioButtonPanel = new JPanel();
RadioButtonPanel.setBackgr ound(Color .white);
JoinSupportPanel = new JPanel();
JoinSupportPanel.setBackgr ound(Color .white);
ReminderPanel = new JPanel();
ReminderPanel.setBackgroun d(Color.wh ite);
TitlePanel = new JPanel();
TitlePanel.setBackground(C olor.white );
// Designate Layout
ButtonsPanel.setLayout(new FlowLayout(FlowLayout.CENT ER));
NamePanel.setLayout(new FlowLayout(FlowLayout.LEFT ));
AddressPanel.setLayout(new FlowLayout(FlowLayout.LEFT ));
CityPanel.setLayout(new FlowLayout(FlowLayout.LEFT ));
PhonePanel.setLayout(new FlowLayout(FlowLayout.LEFT ));
EmailPanel.setLayout(new FlowLayout(FlowLayout.LEFT ));
DeliverDatePanel.setLayout (new FlowLayout(FlowLayout.LEFT ));
DeliverTimePanel.setLayout (new FlowLayout(FlowLayout.LEFT ));
RadioButtonPanel.setLayout (new FlowLayout(FlowLayout.LEFT ));
JoinSupportPanel.setLayout (new FlowLayout(FlowLayout.LEFT ));
ReminderPanel.setLayout(ne w FlowLayout(FlowLayout.LEFT ));
TitlePanel.setLayout(new FlowLayout(FlowLayout.CENT ER));
SelectPanel.setLayout(new FlowLayout(FlowLayout.RIGH T));
ThinMintsPanel.setLayout(n ew FlowLayout(FlowLayout.RIGH T));
CarDelightPanel.setLayout( new FlowLayout(FlowLayout.RIGH T));
ShortBreadPanel.setLayout( new FlowLayout(FlowLayout.RIGH T));
PBPattiesPanel.setLayout(n ew FlowLayout(FlowLayout.RIGH T));
PBSandwichPanel.setLayout( new FlowLayout(FlowLayout.RIGH T));
LemonPastryPanel.setLayout (new FlowLayout(FlowLayout.RIGH T));
CustomerPanel.setLayout(ne w GridLayout(10,1));
CustomerPanel.add(NamePane l);
CustomerPanel.add(AddressP anel);
CustomerPanel.add(CityPane l);
CustomerPanel.add(PhonePan el);
CustomerPanel.add(EmailPan el);
CustomerPanel.add(DeliverD atePanel);
CustomerPanel.add(DeliverT imePanel);
CustomerPanel.add(RadioBut tonPanel);
CustomerPanel.add(JoinSupp ortPanel);
CustomerPanel.add(Reminder Panel);
CustomerPanel.setBackgroun d(Color.wh ite);
CookiePanel.setLayout(new GridLayout(7,1));
CookiePanel.add(SelectPane l);
CookiePanel.add(ThinMintsP anel);
CookiePanel.add(CarDelight Panel);
CookiePanel.add(ShortBread Panel);
CookiePanel.add(PBPattiesP anel);
CookiePanel.add(PBSandwich Panel);
CookiePanel.add(LemonPastr yPanel);
Panel.setLayout(new BorderLayout ());
Panel.add(TitlePanel, BorderLayout.NORTH);
Panel.add(CustomerPanel, BorderLayout.WEST);
Panel.add(CookiePanel, BorderLayout.EAST);
Panel.add(ButtonsPanel, BorderLayout.SOUTH);
// Create Image Instance
GSLogo = new ImageIcon("images/gslogo.j pg");
JLabel GSLogoLabel = new JLabel(GSLogo);
Cookies = new ImageIcon("images/cookies. jpg");
JLabel CookiesLabel = new JLabel(Cookies);
// Focus Cursor in Name Text Field
JTFName.requestFocus();
// Add GUI Components to Panel
TitlePanel.add(GSLogoLabel );
TitlePanel.add(JLTitle);
NamePanel.add(JLName);
NamePanel.add(JTFName);
AddressPanel.add(JLAddress );
AddressPanel.add(JTFAddres s);
CityPanel.add(JLCity);
CityPanel.add(JTFCity);
PhonePanel.add(JLPhone);
PhonePanel.add(JTFPhone);
EmailPanel.add(JLEmail);
EmailPanel.add(JTFEmail);
CookiePanel.add(JLCookies) ;
CookiePanel.add(JLThinMint s);
CookiePanel.add(JComBoxThi nMints);
CookiePanel.add(JLCarDelig ht);
CookiePanel.add(JComBoxCar Delight);
CookiePanel.add(JLShortBre ad);
CookiePanel.add(JComBoxSho rtBread);
CookiePanel.add(JLPBPattie s);
CookiePanel.add(JComBoxPBP atties);
CookiePanel.add(JLPBSandwi ch);
CookiePanel.add(JComBoxPBS andwich);
CookiePanel.add(JLLemonPas try);
CookiePanel.add(JComBoxLem onPastry);
DeliverDatePanel.add(JLDel iverDate);
DeliverDatePanel.add(JComB oxDeliverD ate);
DeliverTimePanel.add(JLDel iverTime);
DeliverTimePanel.add(JRBDT TwelveTwo) ;
RadioButtonPanel.add(JRBDT TwoFour);
RadioButtonPanel.add(JRBDT FourSix);
RadioButtonPanel.add(JRBDT SixEight);
JoinSupportPanel.add(JCBJo inSupportG S);
JoinSupportPanel.add(JLJoi nSupportGS );
ReminderPanel.add(JCBRemin der);
ReminderPanel.add(JLRemind er);
ButtonsPanel.add(JBSubmit) ;
ButtonsPanel.add(JBClear);
ButtonsPanel.add(JLStateme nt);
ButtonsPanel.add(CookiesLa bel);
// Action Listener OLD PROGRAM STUFF
JBSubmit.addActionListener (new java.awt.event.ActionListe ner() {
public void actionPerformed(java.awt.e vent.Actio nEvent evt) {
// Get Information Entered by Customer
String Name = JTFName.getText();
String Address = JTFAddress.getText();
String City = JTFCity.getText();
String Phone = JTFPhone.getText();
String Email = JTFEmail.getText();
String ThinMints = (String)JComBoxThinMints.g etSelected Item();
String CarDelight = (String)JComBoxCarDelight. getSelecte dItem();
String ShortBread = (String)JComBoxShortBread. getSelecte dItem();
String PBPatties = (String)JComBoxPBPatties.g etSelected Item();
String PBSandwich = (String)JComBoxPBSandwich. getSelecte dItem();
String LemonPastry = (String)JComBoxLemonPastry .getSelect edItem();
String DeliverDate = (String)JComBoxDeliverDate .getSelect edItem();
// Add Gotten Data to Output String for Receipt
output += ("Name: " + Name + "\n");
output += ("Address: " + Address + City + "\n");
output += ("Phone Number: " + Phone + " \n");
output += ("E-mail Address: " + Email + "\n\n");
output += ("Number of Each Type of Cookie: \n");
output += ("Thin Mints: " + ThinMints + "\n");
output += ("Caramel Delights: " + CarDelight + "\n");
output += ("Short Bread: " + ShortBread + "\n");
output += ("Peanut Butter Patties: " + PBPatties + "\n");
output += ("Peanut Butter Sandwiches: " + PBSandwich + "\n");
output += ("Lemon Pastry: " + LemonPastry + "\n\n");
output += ("Preferred Delivery Date: " + DeliverDate + "\n");
output += ("Preferred Delivery Time: ");
// Get Preferred Delivery Time
final String TwelveTwo, TwoFour, FourSix, SixEight;
if (JRBDTTwelveTwo.isSelected () == true) {
TwelveTwo = "12:00-2:00";
output += (TwelveTwo);
}
else if (JRBDTTwoFour.isSelected() == true) {
TwoFour = "2:00-4:00";
output += (TwoFour);
}
else if (JRBDTFourSix.isSelected() == true) {
FourSix = "4:00-6:00";
output += (FourSix);
}
else if (JRBDTSixEight.isSelected( ) == true) {
SixEight = "6:00-8:00";
output += (SixEight);
}
output += ("\n\n");
// See if Option Boxes are Checked
final String JoinSupportGS, Reminder;
if (JCBJoinSupportGS.isSelect ed() == true) {
JoinSupportGS = "E-mail me about how to join/support Girl Scouts";
output += (JoinSupportGS + "\n");
}
if (JCBReminder.isSelected() == true) {
Reminder = "E-mail me/call me to remind me the day before delivery";
output += (Reminder);
}
// Find Total Amount Owed for Cookies
double ThinMintsNum = Double.parseDouble(ThinMin ts);
double ThinMintTotal = ThinMintsNum * 3;
double CarDelightNum = Double.parseDouble(CarDeli ght);
double CarDelightTotal = CarDelightNum * 3;
double ShortBreadNum = Double.parseDouble(ShortBr ead);
double ShortBreadTotal = ShortBreadNum * 3;
double PBPattiesNum = Double.parseDouble(PBPatti es);
double PBPattiesTotal = PBPattiesNum * 3;
double PBSandwichNum = Double.parseDouble(PBSandw ich);
double PBSandwichTotal = PBSandwichNum * 3;
double LemonPastryNum = Double.parseDouble(LemonPa stry);
double LemonPastryTotal = LemonPastryNum * 3;
double total = ThinMintTotal + CarDelightTotal + ShortBreadTotal + PBPattiesTotal + PBSandwichTotal + LemonPastryTotal;
DecimalFormat totalFormat = new DecimalFormat("###.00");
output += ("\n\nTOTAL: $" + totalFormat.format(total)) ;
output += ("\n\n");
output += ("Money will be collected when cookies are delivered. Thank you for supporting your local Girl Scouts.");
// Output Receipt in JTextArea
JTextArea displayReceipt = new JTextArea();
displayReceipt.setText(out put);
displayReceipt.setEditable (false);
JOptionPane.showMessageDia log (null, displayReceipt, "Receipt", JOptionPane.INFORMATION_ME SSAGE);
}
});
// Action Listener for Clear Button, Resets all Text
JBClear.addActionListener( new java.awt.event.ActionListe ner() {
public void actionPerformed(java.awt.e vent.Actio nEvent evt) {
JTFName.setText("");
JTFAddress.setText("");
JTFCity.setText("");
JTFPhone.setText("");
JTFEmail.setText("");
JComBoxThinMints.setSelect edIndex(0) ;
JComBoxCarDelight.setSelec tedIndex(0 );
JComBoxShortBread.setSelec tedIndex(0 );
JComBoxPBPatties.setSelect edIndex(0) ;
JComBoxPBSandwich.setSelec tedIndex(0 );
JComBoxLemonPastry.setSele ctedIndex( 0);
JComBoxDeliverDate.setSele ctedIndex( 0);
JRBDTTwelveTwo.setSelected (true);
JRBDTTwoFour.setSelected(f alse);
JRBDTFourSix.setSelected(f alse);
JRBDTSixEight.setSelected( false);
JCBJoinSupportGS.setSelect ed(false);
JCBReminder.setSelected(fa lse);
}
});
// Output User Interface
JFrame Frame = new JFrame();
Frame.getContentPane().add (Panel);
// Frame.getContentPane().set Layout(new FlowLayout());
// Frame.getContentPane().set Layout(new GridLayout());
// Frame.getContentPane().set Layout(new BorderLayout());
Frame.setSize(800,600);
Frame.setVisible(true);
Frame.setDefaultCloseOpera tion(JFram e.EXIT_ON_ CLOSE);
/*
JFrame Frame = new JFrame();
Frame.getContentPane().add (Panel);
Frame.setLayout(new FlowLayout());
Frame.setSize(275,175);
Frame.setVisible(true);
*/
}
}
Thanks,
Erica
package Project5;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.text.*;
import javax.swing.JOptionPane;
import javax.swing.JTextArea;
import java.text.NumberFormat;
public class Project5 {
public static String output = ("");
public static void main(String[] args) {
// Declare GUI Components and Variables
JLabel JLTitle,
JLName,
JLAddress,
JLCity,
JLPhone,
JLEmail,
JLCookies,
JLThinMints,
JLCarDelight,
JLShortBread,
JLPBPatties,
JLPBSandwich,
JLLemonPastry,
JLDeliverDate,
JLDeliverTime,
JLJoinSupportGS,
JLReminder,
JLStatement;
final JTextField JTFName,
JTFAddress,
JTFCity,
JTFPhone,
JTFEmail;
JButton JBSubmit,
JBClear;
final JComboBox JComBoxThinMints,
JComBoxCarDelight,
JComBoxShortBread,
JComBoxPBPatties,
JComBoxPBSandwich,
JComBoxLemonPastry,
JComBoxDeliverDate;
final JRadioButton JRBDTTwelveTwo,
JRBDTTwoFour,
JRBDTFourSix,
JRBDTSixEight;
final JCheckBox JCBJoinSupportGS,
JCBReminder;
JPanel Panel,
CustomerPanel,
ButtonsPanel,
NamePanel,
AddressPanel,
CityPanel,
PhonePanel,
EmailPanel,
SelectPanel,
CookiePanel,
ThinMintsPanel,
CarDelightPanel,
ShortBreadPanel,
PBPattiesPanel,
PBSandwichPanel,
LemonPastryPanel,
DeliverDatePanel,
DeliverTimePanel,
RadioButtonPanel,
JoinSupportPanel,
ReminderPanel,
TitlePanel;
Icon GSLogo,
Cookies;
// Assign Text to JLabels
JLTitle = new JLabel("Girl Scout Cookie Order Form");
Color GSGreen = new Color (27,152,14);
JLTitle.setForeground(GSGr
Font TitleFont = new Font("Courier",Font.BOLD,2
JLTitle.setFont(TitleFont)
JLName = new JLabel("Name: ");
JLAddress = new JLabel("Street Address: ");
JLCity = new JLabel("City: ");
JLPhone = new JLabel("Phone Number: ");
JLEmail = new JLabel("E-mail Address: ");
JLCookies = new JLabel("Select How Many Boxes You Would Like: ");
JLThinMints = new JLabel("Thin Mints ");
JLCarDelight = new JLabel("Caramel Delights ");
JLShortBread = new JLabel("Short Bread ");
JLPBPatties = new JLabel("Peanut Butter Patties ");
JLPBSandwich = new JLabel("Peanut Butter Sandwiches ");
JLLemonPastry = new JLabel("Lemon Pastry ");
JLDeliverDate = new JLabel("Preferred Delivery Date: ");
JLDeliverTime = new JLabel("Preferred Delivery Time: ");
JLJoinSupportGS = new JLabel("");
JLReminder = new JLabel("");
JLStatement = new JLabel("Money will be collected when cookies are delivered. Thank you for supporting your local Girl Scouts.");
// Assign Lengths to Text Fields
JTFName = new JTextField(15);
JTFAddress = new JTextField(25);
JTFCity = new JTextField(15);
JTFPhone = new JTextField(15);
JTFEmail = new JTextField(15);
// Assign Text to Buttons
JBClear = new JButton("Clear");
JBSubmit = new JButton("Sumit");
// Array of Numbers for JComboBox
String[] numCookies = {
"0","1","2","3","4","5","6
"15","16","17","18","19","
// Array of Delivery Dates for JComBoxDeliverDate
String[] deliverDates = {"Sunday","Monday","Tuesda
// Assign Contents to JComboBoxes
JComBoxThinMints = new JComboBox(numCookies);
JComBoxThinMints.setBackgr
JComBoxCarDelight = new JComboBox(numCookies);
JComBoxCarDelight.setBackg
JComBoxShortBread = new JComboBox(numCookies);
JComBoxShortBread.setBackg
JComBoxPBPatties = new JComboBox(numCookies);
JComBoxPBPatties.setBackgr
JComBoxPBSandwich = new JComboBox(numCookies);
JComBoxPBSandwich.setBackg
JComBoxLemonPastry = new JComboBox(numCookies);
JComBoxLemonPastry.setBack
JComBoxDeliverDate = new JComboBox(deliverDates);
JComBoxDeliverDate.setBack
// Assign Functionality and Text to Radio Buttons
JRBDTTwelveTwo = new JRadioButton("12:00-2:00",
JRBDTTwelveTwo.setBackgrou
JRBDTTwoFour = new JRadioButton("2:00-4:00",f
JRBDTTwoFour.setBackground
JRBDTFourSix = new JRadioButton("4:00-6:00",f
JRBDTFourSix.setBackground
JRBDTSixEight = new JRadioButton("6:00-8:00",f
JRBDTSixEight.setBackgroun
ButtonGroup deliverTime = new ButtonGroup();
deliverTime.add(JRBDTTwelv
deliverTime.add(JRBDTTwoFo
deliverTime.add(JRBDTFourS
deliverTime.add(JRBDTSixEi
// Assign Functionality and Text to Check Boxes
JCBJoinSupportGS = new JCheckBox(" E-mail me about how to join/support Girl Scouts",false);
JCBJoinSupportGS.setBackgr
JCBReminder = new JCheckBox(" E-mail me/call me to remind me the day before delivery",false);
JCBReminder.setBackground(
// Create Panels
Panel = new JPanel();
Panel.setBackground(Color.
CustomerPanel = new JPanel();
CustomerPanel.setBackgroun
ButtonsPanel = new JPanel();
ButtonsPanel.setBackground
NamePanel = new JPanel();
NamePanel.setBackground(Co
AddressPanel = new JPanel();
AddressPanel.setBackground
CityPanel = new JPanel();
CityPanel.setBackground(Co
PhonePanel = new JPanel();
PhonePanel.setBackground(C
EmailPanel = new JPanel();
EmailPanel.setBackground(C
CookiePanel = new JPanel();
CookiePanel.setBackground(
SelectPanel = new JPanel();
SelectPanel.setBackground(
ThinMintsPanel = new JPanel();
ThinMintsPanel.setBackgrou
CarDelightPanel = new JPanel();
CarDelightPanel.setBackgro
ShortBreadPanel = new JPanel();
ShortBreadPanel.setBackgro
PBPattiesPanel = new JPanel();
PBPattiesPanel.setBackgrou
PBSandwichPanel = new JPanel();
PBSandwichPanel.setBackgro
LemonPastryPanel = new JPanel();
LemonPastryPanel.setBackgr
DeliverDatePanel = new JPanel();
DeliverDatePanel.setBackgr
DeliverTimePanel = new JPanel();
DeliverTimePanel.setBackgr
RadioButtonPanel = new JPanel();
RadioButtonPanel.setBackgr
JoinSupportPanel = new JPanel();
JoinSupportPanel.setBackgr
ReminderPanel = new JPanel();
ReminderPanel.setBackgroun
TitlePanel = new JPanel();
TitlePanel.setBackground(C
// Designate Layout
ButtonsPanel.setLayout(new
NamePanel.setLayout(new FlowLayout(FlowLayout.LEFT
AddressPanel.setLayout(new
CityPanel.setLayout(new FlowLayout(FlowLayout.LEFT
PhonePanel.setLayout(new FlowLayout(FlowLayout.LEFT
EmailPanel.setLayout(new FlowLayout(FlowLayout.LEFT
DeliverDatePanel.setLayout
DeliverTimePanel.setLayout
RadioButtonPanel.setLayout
JoinSupportPanel.setLayout
ReminderPanel.setLayout(ne
TitlePanel.setLayout(new FlowLayout(FlowLayout.CENT
SelectPanel.setLayout(new FlowLayout(FlowLayout.RIGH
ThinMintsPanel.setLayout(n
CarDelightPanel.setLayout(
ShortBreadPanel.setLayout(
PBPattiesPanel.setLayout(n
PBSandwichPanel.setLayout(
LemonPastryPanel.setLayout
CustomerPanel.setLayout(ne
CustomerPanel.add(NamePane
CustomerPanel.add(AddressP
CustomerPanel.add(CityPane
CustomerPanel.add(PhonePan
CustomerPanel.add(EmailPan
CustomerPanel.add(DeliverD
CustomerPanel.add(DeliverT
CustomerPanel.add(RadioBut
CustomerPanel.add(JoinSupp
CustomerPanel.add(Reminder
CustomerPanel.setBackgroun
CookiePanel.setLayout(new GridLayout(7,1));
CookiePanel.add(SelectPane
CookiePanel.add(ThinMintsP
CookiePanel.add(CarDelight
CookiePanel.add(ShortBread
CookiePanel.add(PBPattiesP
CookiePanel.add(PBSandwich
CookiePanel.add(LemonPastr
Panel.setLayout(new BorderLayout ());
Panel.add(TitlePanel, BorderLayout.NORTH);
Panel.add(CustomerPanel, BorderLayout.WEST);
Panel.add(CookiePanel, BorderLayout.EAST);
Panel.add(ButtonsPanel, BorderLayout.SOUTH);
// Create Image Instance
GSLogo = new ImageIcon("images/gslogo.j
JLabel GSLogoLabel = new JLabel(GSLogo);
Cookies = new ImageIcon("images/cookies.
JLabel CookiesLabel = new JLabel(Cookies);
// Focus Cursor in Name Text Field
JTFName.requestFocus();
// Add GUI Components to Panel
TitlePanel.add(GSLogoLabel
TitlePanel.add(JLTitle);
NamePanel.add(JLName);
NamePanel.add(JTFName);
AddressPanel.add(JLAddress
AddressPanel.add(JTFAddres
CityPanel.add(JLCity);
CityPanel.add(JTFCity);
PhonePanel.add(JLPhone);
PhonePanel.add(JTFPhone);
EmailPanel.add(JLEmail);
EmailPanel.add(JTFEmail);
CookiePanel.add(JLCookies)
CookiePanel.add(JLThinMint
CookiePanel.add(JComBoxThi
CookiePanel.add(JLCarDelig
CookiePanel.add(JComBoxCar
CookiePanel.add(JLShortBre
CookiePanel.add(JComBoxSho
CookiePanel.add(JLPBPattie
CookiePanel.add(JComBoxPBP
CookiePanel.add(JLPBSandwi
CookiePanel.add(JComBoxPBS
CookiePanel.add(JLLemonPas
CookiePanel.add(JComBoxLem
DeliverDatePanel.add(JLDel
DeliverDatePanel.add(JComB
DeliverTimePanel.add(JLDel
DeliverTimePanel.add(JRBDT
RadioButtonPanel.add(JRBDT
RadioButtonPanel.add(JRBDT
RadioButtonPanel.add(JRBDT
JoinSupportPanel.add(JCBJo
JoinSupportPanel.add(JLJoi
ReminderPanel.add(JCBRemin
ReminderPanel.add(JLRemind
ButtonsPanel.add(JBSubmit)
ButtonsPanel.add(JBClear);
ButtonsPanel.add(JLStateme
ButtonsPanel.add(CookiesLa
// Action Listener OLD PROGRAM STUFF
JBSubmit.addActionListener
public void actionPerformed(java.awt.e
// Get Information Entered by Customer
String Name = JTFName.getText();
String Address = JTFAddress.getText();
String City = JTFCity.getText();
String Phone = JTFPhone.getText();
String Email = JTFEmail.getText();
String ThinMints = (String)JComBoxThinMints.g
String CarDelight = (String)JComBoxCarDelight.
String ShortBread = (String)JComBoxShortBread.
String PBPatties = (String)JComBoxPBPatties.g
String PBSandwich = (String)JComBoxPBSandwich.
String LemonPastry = (String)JComBoxLemonPastry
String DeliverDate = (String)JComBoxDeliverDate
// Add Gotten Data to Output String for Receipt
output += ("Name: " + Name + "\n");
output += ("Address: " + Address + City + "\n");
output += ("Phone Number: " + Phone + " \n");
output += ("E-mail Address: " + Email + "\n\n");
output += ("Number of Each Type of Cookie: \n");
output += ("Thin Mints: " + ThinMints + "\n");
output += ("Caramel Delights: " + CarDelight + "\n");
output += ("Short Bread: " + ShortBread + "\n");
output += ("Peanut Butter Patties: " + PBPatties + "\n");
output += ("Peanut Butter Sandwiches: " + PBSandwich + "\n");
output += ("Lemon Pastry: " + LemonPastry + "\n\n");
output += ("Preferred Delivery Date: " + DeliverDate + "\n");
output += ("Preferred Delivery Time: ");
// Get Preferred Delivery Time
final String TwelveTwo, TwoFour, FourSix, SixEight;
if (JRBDTTwelveTwo.isSelected
TwelveTwo = "12:00-2:00";
output += (TwelveTwo);
}
else if (JRBDTTwoFour.isSelected()
TwoFour = "2:00-4:00";
output += (TwoFour);
}
else if (JRBDTFourSix.isSelected()
FourSix = "4:00-6:00";
output += (FourSix);
}
else if (JRBDTSixEight.isSelected(
SixEight = "6:00-8:00";
output += (SixEight);
}
output += ("\n\n");
// See if Option Boxes are Checked
final String JoinSupportGS, Reminder;
if (JCBJoinSupportGS.isSelect
JoinSupportGS = "E-mail me about how to join/support Girl Scouts";
output += (JoinSupportGS + "\n");
}
if (JCBReminder.isSelected() == true) {
Reminder = "E-mail me/call me to remind me the day before delivery";
output += (Reminder);
}
// Find Total Amount Owed for Cookies
double ThinMintsNum = Double.parseDouble(ThinMin
double ThinMintTotal = ThinMintsNum * 3;
double CarDelightNum = Double.parseDouble(CarDeli
double CarDelightTotal = CarDelightNum * 3;
double ShortBreadNum = Double.parseDouble(ShortBr
double ShortBreadTotal = ShortBreadNum * 3;
double PBPattiesNum = Double.parseDouble(PBPatti
double PBPattiesTotal = PBPattiesNum * 3;
double PBSandwichNum = Double.parseDouble(PBSandw
double PBSandwichTotal = PBSandwichNum * 3;
double LemonPastryNum = Double.parseDouble(LemonPa
double LemonPastryTotal = LemonPastryNum * 3;
double total = ThinMintTotal + CarDelightTotal + ShortBreadTotal + PBPattiesTotal + PBSandwichTotal + LemonPastryTotal;
DecimalFormat totalFormat = new DecimalFormat("###.00");
output += ("\n\nTOTAL: $" + totalFormat.format(total))
output += ("\n\n");
output += ("Money will be collected when cookies are delivered. Thank you for supporting your local Girl Scouts.");
// Output Receipt in JTextArea
JTextArea displayReceipt = new JTextArea();
displayReceipt.setText(out
displayReceipt.setEditable
JOptionPane.showMessageDia
}
});
// Action Listener for Clear Button, Resets all Text
JBClear.addActionListener(
public void actionPerformed(java.awt.e
JTFName.setText("");
JTFAddress.setText("");
JTFCity.setText("");
JTFPhone.setText("");
JTFEmail.setText("");
JComBoxThinMints.setSelect
JComBoxCarDelight.setSelec
JComBoxShortBread.setSelec
JComBoxPBPatties.setSelect
JComBoxPBSandwich.setSelec
JComBoxLemonPastry.setSele
JComBoxDeliverDate.setSele
JRBDTTwelveTwo.setSelected
JRBDTTwoFour.setSelected(f
JRBDTFourSix.setSelected(f
JRBDTSixEight.setSelected(
JCBJoinSupportGS.setSelect
JCBReminder.setSelected(fa
}
});
// Output User Interface
JFrame Frame = new JFrame();
Frame.getContentPane().add
// Frame.getContentPane().set
// Frame.getContentPane().set
// Frame.getContentPane().set
Frame.setSize(800,600);
Frame.setVisible(true);
Frame.setDefaultCloseOpera
/*
JFrame Frame = new JFrame();
Frame.getContentPane().add
Frame.setLayout(new FlowLayout());
Frame.setSize(275,175);
Frame.setVisible(true);
*/
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Actually I figured it out...That second cluster is supposed to be:
CookiePanel.add(JLCookies) ;
ThinMintsPanel.add(JLThinM ints);
ThinMintsPanel.add(JComBox ThinMints) ;
CarDelightPanel.add(JLCarD elight);
CarDelightPanel.add(JComBo xCarDeligh t);
ShortBreadPanel.add(JLShor tBread);
ShortBreadPanel.add(JComBo xShortBrea d);
PBPattiesPanel.add(JLPBPat ties);
PBPattiesPanel.add(JComBox PBPatties) ;
PBSandwichPanel.add(JLPBSa ndwich);
PBSandwichPanel.add(JComBo xPBSandwic h);
LemonPastryPanel.add(JLLem onPastry);
LemonPastryPanel.add(JComB oxLemonPas try);
But now try replacing it and running it...it's still messed up, is there any way to set the size for the East border so it's one right after another vertically?
CookiePanel.add(JLCookies)
ThinMintsPanel.add(JLThinM
ThinMintsPanel.add(JComBox
CarDelightPanel.add(JLCarD
CarDelightPanel.add(JComBo
ShortBreadPanel.add(JLShor
ShortBreadPanel.add(JComBo
PBPattiesPanel.add(JLPBPat
PBPattiesPanel.add(JComBox
PBSandwichPanel.add(JLPBSa
PBSandwichPanel.add(JComBo
LemonPastryPanel.add(JLLem
LemonPastryPanel.add(JComB
But now try replacing it and running it...it's still messed up, is there any way to set the size for the East border so it's one right after another vertically?
ASKER
Actually CookiePanel.add(JLCookies) ;
is supposed to be
SelectPanel.add(JLCookies) ;
So it works now except for my bottom image being cut off no matter how I resize the window
is supposed to be
SelectPanel.add(JLCookies)
So it works now except for my bottom image being cut off no matter how I resize the window
>>Actually CookiePanel.add(JLCookies) ;
>>is supposed to be
>>SelectPanel.add(JLCookie s);
That's what I supposed, yes. ;°)
>>is supposed to be
>>SelectPanel.add(JLCookie
That's what I supposed, yes. ;°)
ASKER
Thanks for the brain spark!
Here are your points
Here are your points
Remark: The button "Sumit" must be "Submit" (typo)
ASKER
Oopsy thanks
Thanks
:)
ASKER
Combo
Combo
Combo
Vertical, not Horizontal
But if I take out the second cluster you posted, none show up at all