title: Positioning panels and components in main panel/frame
body: <p>I have to create a form that has input values for things such as username, password, and other things. here is a link to an image of what it looks like, <a href="http://img196.imageshack.us/img196/1727/empdesign.png" rel="nofollow">http://img196.imageshack.us/img196/1727/empdesign.png</a></p>
  
  <p>I want that all these attributes are alligned to the edge of the screen, and not centered. I tried using the method JComponenet.setHorizontalAlignment(SwingConstants.LEFT), but that also does nothing. I tried that method on JLabels, and JPanels, but neither have an effect. </p>
  
  <p>Here is my code: </p>
  
  <pre><code>public class tada extends GUIDesign{
  
    //making all the jlabels to be placed
  
  JLabel usernameLabel = new JLabel("username");
  JLabel passwordLabel = new JLabel("Name");
  JLabel empIDLabel = new JLabel("empID");
  JLabel SalaryLabel = new JLabel("Salary");
  JLabel EmployerLabel = new JLabel(" Salary");
  JLabel hoursLabel = new JLabel("Gender");
  
  JLabel departmentLabel = new JLabel("Department");
  
  
  
   //making all the textfields, combo boxes, and etc. 
  JTextField usernameField = new JTextField(20);
  JTextField passwordField = new JTextField(20);
  JTextField empIDField = new JTextField(20);
  
  
  JTextField SalaryField = new JTextField(20);
  JTextField EmployerField = new JTextField(20);
  String[] hourss = {"Fall", "Spring", "Summer"};
  JComboBox hoursBox = new JComboBox(hourss);
  
  JCheckBox[] departmentCheckBoxesBoxs = {new JCheckBox("Department 1"), 
                                          new JCheckBox("Department 2"), 
                                          new JCheckBox("Department 3"), 
                                          new JCheckBox("Department 4"), 
                                          new JCheckBox("Department 5")};
  
  
  
  
  
  
  String[] Salary = {"section", "combo", "box"};
  JComboBox sectionBox = new JComboBox(Salary);
  
  
  //making all the panels to be placed inside the main panel. 
  
  JPanel usernamePanel = new JPanel();
  JPanel passwordPanel = new JPanel();
  JPanel empIDPanel = new JPanel();
  JPanel SalaryPanel = new JPanel();
  JPanel EmployerPanel = new JPanel();
  JPanel hoursPanel = new JPanel();
  JPanel departmentsPanel = new JPanel();
  
  JPanel top, bottom;
  
  
  JButton submitButton = new JButton("Submit");
  
  public tada(){
  </code></pre>
  
  <p>//this initializes the panel from superclass. nothing really important inherited from superclass. 
      super("employer design", 10);</p>
  
  <pre><code>    setPreferredSize(new Dimension(400,600));
  </code></pre>
  
  <p>//adding all the labels, text fields, etc to the sub-panels, and adding subpanels to main pannel, bottom.
      setLayout(new BoxLayout(this,BoxLayout.PAGE_AXIS));
          top = new JPanel();
          top.setSize(getWidth(), 30);
          bottom = new JPanel();
          bottom.setLayout(new BoxLayout(bottom,BoxLayout.Y_AXIS));</p>
  
  <pre><code>    top.setBackground(Color.red);
      title.setFont(new Font("Helvetica", 1,20));
      top.add(title);
      bottom.setBackground(Color.yellow);
  
      usernamePanel.add(usernameLabel);
      usernamePanel.add(usernameField);
      bottom.add(usernamePanel);
  
      passwordPanel.add(passwordLabel);
      passwordPanel.add(passwordField);
      bottom.add(passwordPanel);
  
      empIDPanel.add(empIDLabel);
      empIDPanel.add(empIDField);
      bottom.add(empIDPanel);
  
      SalaryPanel.add(SalaryLabel);
      SalaryPanel.add(SalaryField);
      bottom.add(SalaryPanel);
  
      EmployerPanel.add(EmployerLabel);
      EmployerPanel.add(EmployerField);
      bottom.add(EmployerPanel);
  
      hoursPanel.add(hoursLabel);
      hoursPanel.add(hoursBox);
      bottom.add(hoursPanel);
  
      departmentsPanel.add(departmentLabel);
      for(JCheckBox jbc: departmentCheckBoxesBoxs)
      {
          departmentsPanel.add(jbc);
      }
      bottom.add(departmentsPanel);
  
  
  
  
      add(top);
      add(bottom);
  
  
  }
  </code></pre>
  
  <p>//also, since I am using a boxLayout(), and it is alligned to the y_axis, I thought that it would atomatically do the y-axis allignment, but it doesn't. </p>