title: Jframe help Using Boxlayout
body: <p>Hello guys :D i am trying to place a button in G-U-I when someone press a button, and i was able to do so. but i have a problem, first, in my code it seems the box layout is not working. i mean i want the button to appear beneath the add command button but it appears on right side of it (because of flow layout i guess).
  code-</p>
  
  <pre><code>static JLabel name=new JLabel("TESTING123");
  static JButton add=new JButton("Add New Command");
  static JButton a=new JButton("Press Me To Set Command Number 1");
  static JPanel panel=new JPanel();
  static JFrame frame=new JFrame("TEST FRAME");
  
  public static void init(){
  
  
  
      frame.getContentPane().setBackground(Color.WHITE);
      frame.setLayout(new BoxLayout(frame.getContentPane(),BoxLayout.Y_AXIS));//THIS IS NOT WORKING
      //======================================================SOME FRAME PROPERTIES
  
      panel.add(name);
      panel.add(add);
  
      //======================================================ADDING TO PANELS
      add.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
              panel.add(a);
              frame.repaint();
              frame.validate();
  
          }
      });
      //======================================================LISTENERS
  
  
  
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.add(panel);
      frame.setSize(450,500);
      frame.setVisible(true);
  
  
  }
  </code></pre>