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(GSGreen);
    Font TitleFont = new Font("Courier",Font.BOLD,26);
    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","Tuesday","Wednesday","Thursday","Friday","Saturday"};

// Assign Contents to JComboBoxes
    JComBoxThinMints = new JComboBox(numCookies);
    JComBoxThinMints.setBackground(Color.white);
    JComBoxCarDelight = new JComboBox(numCookies);
    JComBoxCarDelight.setBackground(Color.white);
    JComBoxShortBread = new JComboBox(numCookies);
    JComBoxShortBread.setBackground(Color.white);
    JComBoxPBPatties = new JComboBox(numCookies);
    JComBoxPBPatties.setBackground(Color.white);
    JComBoxPBSandwich = new JComboBox(numCookies);
    JComBoxPBSandwich.setBackground(Color.white);
    JComBoxLemonPastry = new JComboBox(numCookies);
    JComBoxLemonPastry.setBackground(Color.white);
    JComBoxDeliverDate = new JComboBox(deliverDates);
    JComBoxDeliverDate.setBackground(Color.white);

// Assign Functionality and Text to Radio Buttons
    JRBDTTwelveTwo = new JRadioButton("12:00-2:00",true);
    JRBDTTwelveTwo.setBackground(Color.white);
    JRBDTTwoFour = new JRadioButton("2:00-4:00",false);
    JRBDTTwoFour.setBackground(Color.white);
    JRBDTFourSix = new JRadioButton("4:00-6:00",false);
    JRBDTFourSix.setBackground(Color.white);
    JRBDTSixEight = new JRadioButton("6:00-8:00",false);
    JRBDTSixEight.setBackground(Color.white);
    ButtonGroup deliverTime = new ButtonGroup();
    deliverTime.add(JRBDTTwelveTwo);
    deliverTime.add(JRBDTTwoFour);
    deliverTime.add(JRBDTFourSix);
    deliverTime.add(JRBDTSixEight);

// Assign Functionality and Text to Check Boxes
    JCBJoinSupportGS = new JCheckBox(" E-mail me about how to join/support Girl Scouts",false);
    JCBJoinSupportGS.setBackground(Color.white);
    JCBReminder = new JCheckBox(" E-mail me/call me to remind me the day before delivery",false);
    JCBReminder.setBackground(Color.white);

// Create Panels
    Panel = new JPanel();
    Panel.setBackground(Color.white);
    CustomerPanel = new JPanel();
    CustomerPanel.setBackground(Color.white);
    ButtonsPanel = new JPanel();
    ButtonsPanel.setBackground(Color.white);
    NamePanel = new JPanel();
    NamePanel.setBackground(Color.white);
    AddressPanel = new JPanel();
    AddressPanel.setBackground(Color.white);
    CityPanel = new JPanel();
    CityPanel.setBackground(Color.white);
    PhonePanel = new JPanel();
    PhonePanel.setBackground(Color.white);
    EmailPanel = new JPanel();
    EmailPanel.setBackground(Color.white);
    CookiePanel = new JPanel();
    CookiePanel.setBackground(Color.white);
    SelectPanel = new JPanel();
    SelectPanel.setBackground(Color.white);
    ThinMintsPanel = new JPanel();
    ThinMintsPanel.setBackground(Color.white);
    CarDelightPanel = new JPanel();
    CarDelightPanel.setBackground(Color.white);
    ShortBreadPanel = new JPanel();
    ShortBreadPanel.setBackground(Color.white);
    PBPattiesPanel = new JPanel();
    PBPattiesPanel.setBackground(Color.white);
    PBSandwichPanel = new JPanel();
    PBSandwichPanel.setBackground(Color.white);
    LemonPastryPanel = new JPanel();
    LemonPastryPanel.setBackground(Color.white);
    DeliverDatePanel = new JPanel();
    DeliverDatePanel.setBackground(Color.white);
    DeliverTimePanel = new JPanel();
    DeliverTimePanel.setBackground(Color.white);
    RadioButtonPanel = new JPanel();
    RadioButtonPanel.setBackground(Color.white);
    JoinSupportPanel = new JPanel();
    JoinSupportPanel.setBackground(Color.white);
    ReminderPanel = new JPanel();
    ReminderPanel.setBackground(Color.white);
    TitlePanel = new JPanel();
    TitlePanel.setBackground(Color.white);

// Designate Layout
    ButtonsPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
    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(new FlowLayout(FlowLayout.LEFT));
    TitlePanel.setLayout(new FlowLayout(FlowLayout.CENTER));
    SelectPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
    ThinMintsPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
    CarDelightPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
    ShortBreadPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
    PBPattiesPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
    PBSandwichPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
    LemonPastryPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));

    CustomerPanel.setLayout(new GridLayout(10,1));
    CustomerPanel.add(NamePanel);
    CustomerPanel.add(AddressPanel);
    CustomerPanel.add(CityPanel);
    CustomerPanel.add(PhonePanel);
    CustomerPanel.add(EmailPanel);
    CustomerPanel.add(DeliverDatePanel);
    CustomerPanel.add(DeliverTimePanel);
    CustomerPanel.add(RadioButtonPanel);
    CustomerPanel.add(JoinSupportPanel);
    CustomerPanel.add(ReminderPanel);
    CustomerPanel.setBackground(Color.white);

    CookiePanel.setLayout(new GridLayout(7,1));
    CookiePanel.add(SelectPanel);
    CookiePanel.add(ThinMintsPanel);
    CookiePanel.add(CarDelightPanel);
    CookiePanel.add(ShortBreadPanel);
    CookiePanel.add(PBPattiesPanel);
    CookiePanel.add(PBSandwichPanel);
    CookiePanel.add(LemonPastryPanel);

    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.jpg");
    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(JTFAddress);
    CityPanel.add(JLCity);
    CityPanel.add(JTFCity);
    PhonePanel.add(JLPhone);
    PhonePanel.add(JTFPhone);
    EmailPanel.add(JLEmail);
    EmailPanel.add(JTFEmail);
    CookiePanel.add(JLCookies);
    CookiePanel.add(JLThinMints);
    CookiePanel.add(JComBoxThinMints);
    CookiePanel.add(JLCarDelight);
    CookiePanel.add(JComBoxCarDelight);
    CookiePanel.add(JLShortBread);
    CookiePanel.add(JComBoxShortBread);
    CookiePanel.add(JLPBPatties);
    CookiePanel.add(JComBoxPBPatties);
    CookiePanel.add(JLPBSandwich);
    CookiePanel.add(JComBoxPBSandwich);
    CookiePanel.add(JLLemonPastry);
    CookiePanel.add(JComBoxLemonPastry);
    DeliverDatePanel.add(JLDeliverDate);
    DeliverDatePanel.add(JComBoxDeliverDate);
    DeliverTimePanel.add(JLDeliverTime);
    DeliverTimePanel.add(JRBDTTwelveTwo);
    RadioButtonPanel.add(JRBDTTwoFour);
    RadioButtonPanel.add(JRBDTFourSix);
    RadioButtonPanel.add(JRBDTSixEight);
    JoinSupportPanel.add(JCBJoinSupportGS);
    JoinSupportPanel.add(JLJoinSupportGS);
    ReminderPanel.add(JCBReminder);
    ReminderPanel.add(JLReminder);
    ButtonsPanel.add(JBSubmit);
    ButtonsPanel.add(JBClear);
    ButtonsPanel.add(JLStatement);
    ButtonsPanel.add(CookiesLabel);

// Action Listener OLD PROGRAM STUFF
JBSubmit.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent 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.getSelectedItem();
           String CarDelight = (String)JComBoxCarDelight.getSelectedItem();
           String ShortBread = (String)JComBoxShortBread.getSelectedItem();
           String PBPatties = (String)JComBoxPBPatties.getSelectedItem();
           String PBSandwich = (String)JComBoxPBSandwich.getSelectedItem();
           String LemonPastry = (String)JComBoxLemonPastry.getSelectedItem();
           String DeliverDate = (String)JComBoxDeliverDate.getSelectedItem();

// 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.isSelected() == 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(ThinMints);
             double ThinMintTotal = ThinMintsNum * 3;

             double CarDelightNum = Double.parseDouble(CarDelight);
             double CarDelightTotal = CarDelightNum * 3;

             double ShortBreadNum = Double.parseDouble(ShortBread);
             double ShortBreadTotal = ShortBreadNum * 3;

             double PBPattiesNum = Double.parseDouble(PBPatties);
             double PBPattiesTotal = PBPattiesNum * 3;

             double PBSandwichNum = Double.parseDouble(PBSandwich);
             double PBSandwichTotal = PBSandwichNum * 3;

             double LemonPastryNum = Double.parseDouble(LemonPastry);
             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(output);
    displayReceipt.setEditable(false);
    JOptionPane.showMessageDialog (null, displayReceipt, "Receipt", JOptionPane.INFORMATION_MESSAGE);
            }
        });

// Action Listener for Clear Button, Resets all Text
JBClear.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
      JTFName.setText("");
      JTFAddress.setText("");
      JTFCity.setText("");
      JTFPhone.setText("");
      JTFEmail.setText("");
      JComBoxThinMints.setSelectedIndex(0);
      JComBoxCarDelight.setSelectedIndex(0);
      JComBoxShortBread.setSelectedIndex(0);
      JComBoxPBPatties.setSelectedIndex(0);
      JComBoxPBSandwich.setSelectedIndex(0);
      JComBoxLemonPastry.setSelectedIndex(0);
      JComBoxDeliverDate.setSelectedIndex(0);
      JRBDTTwelveTwo.setSelected(true);
      JRBDTTwoFour.setSelected(false);
      JRBDTFourSix.setSelected(false);
      JRBDTSixEight.setSelected(false);
      JCBJoinSupportGS.setSelected(false);
      JCBReminder.setSelected(false);
      }
    });

// Output User Interface
    JFrame Frame = new JFrame();
    Frame.getContentPane().add(Panel);
 //   Frame.getContentPane().setLayout(new FlowLayout());
 //   Frame.getContentPane().setLayout(new GridLayout());
 //   Frame.getContentPane().setLayout(new BorderLayout());
    Frame.setSize(800,600);
    Frame.setVisible(true);
    Frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

/*
JFrame Frame = new JFrame();
Frame.getContentPane().add(Panel);
Frame.setLayout(new FlowLayout());
Frame.setSize(275,175);
Frame.setVisible(true);
*/

  }
}
Job4SuprmnAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

zzynxSoftware engineerCommented:
Sure you want to have both

    CookiePanel.setLayout(new GridLayout(7,1));
    CookiePanel.add(SelectPanel);
    CookiePanel.add(ThinMintsPanel);
    CookiePanel.add(CarDelightPanel);
    CookiePanel.add(ShortBreadPanel);
    CookiePanel.add(PBPattiesPanel);
    CookiePanel.add(PBSandwichPanel);
    CookiePanel.add(LemonPastryPanel);

and

    CookiePanel.add(JLCookies);
    CookiePanel.add(JLThinMints);
    CookiePanel.add(JComBoxThinMints);
    CookiePanel.add(JLCarDelight);
    CookiePanel.add(JComBoxCarDelight);
    CookiePanel.add(JLShortBread);
    CookiePanel.add(JComBoxShortBread);
    CookiePanel.add(JLPBPatties);
    CookiePanel.add(JComBoxPBPatties);
    CookiePanel.add(JLPBSandwich);
    CookiePanel.add(JComBoxPBSandwich);
    CookiePanel.add(JLLemonPastry);
    CookiePanel.add(JComBoxLemonPastry);

?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Job4SuprmnAuthor Commented:
I think I need the Grid Layout so it's not all strung out, I'd like for the Combo Boxes to be like:

Combo
Combo
Combo

Vertical, not Horizontal


But if I take out the second cluster you posted, none show up at all
0
girionisCommented:
Try to use setPreferredSize(Dimension()) on the combo box and see what happens.
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

Job4SuprmnAuthor Commented:
Actually I figured it out...That second cluster is supposed to be:

    CookiePanel.add(JLCookies);
    ThinMintsPanel.add(JLThinMints);
    ThinMintsPanel.add(JComBoxThinMints);
    CarDelightPanel.add(JLCarDelight);
    CarDelightPanel.add(JComBoxCarDelight);
    ShortBreadPanel.add(JLShortBread);
    ShortBreadPanel.add(JComBoxShortBread);
    PBPattiesPanel.add(JLPBPatties);
    PBPattiesPanel.add(JComBoxPBPatties);
    PBSandwichPanel.add(JLPBSandwich);
    PBSandwichPanel.add(JComBoxPBSandwich);
    LemonPastryPanel.add(JLLemonPastry);
    LemonPastryPanel.add(JComBoxLemonPastry);

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?
0
Job4SuprmnAuthor Commented:
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
0
zzynxSoftware engineerCommented:
>>Actually CookiePanel.add(JLCookies);
>>is supposed to be
>>SelectPanel.add(JLCookies);

That's what I supposed, yes. ;°)
0
Job4SuprmnAuthor Commented:
Thanks for the brain spark!
Here are your points
0
zzynxSoftware engineerCommented:
Remark: The button "Sumit" must be "Submit" (typo)
0
Job4SuprmnAuthor Commented:
Oopsy thanks
0
zzynxSoftware engineerCommented:
Thanks
0
girionisCommented:
:)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.