title: Button Layout in java
body: <p>So I am working in java, and have the buttons set up. The only thing I want to do now is separate the buttons by putting so many on one side of the <code>JFrame</code> and so many on the other side of the <code>JFrame</code>. Any suggestions? oh and there is a <code>JList</code> that goes with one of the buttons.</p>
  
  <p>[Update] Just updated my code, and so far, no improvement, still states that it won't open up the GUI.</p>
  
  <pre><code>  package SystemandDesign.RISK;
  
  
  import javax.swing.JButton;
  import java.awt.event.ActionListener;
  import java.awt.event.ActionEvent;
  import javax.swing.JFrame;
  
  //Now for the JList options;
  
  import javax.swing.JList;
  import javax.swing.JScrollPane;
  import javax.swing.event.ListSelectionListener;
  import javax.swing.event.ListSelectionEvent;
  import javax.swing.ListSelectionModel;
  import javax.swing.JPanel;
  //Will be used to created JList options
  
  //Colors to be used for testing purposes.
  
  import java.awt.Color;
  
  //panel to separate buttons.
  import java.awt.GridLayout;
  import java.awt.BorderLayout;
  
  
  public class GamePage extends JFrame{
  
    private JButton surrender;
    private JButton draw;
    private JButton attackRoll;
    private JButton defendRoll;
    private JButton trade;
    private JButton main;
    private JButton quit;
    private JFrame frame;
    private JPanel east;
    private JPanel west;
  
  
  
    private JList terNames;//Used primarily at the beginning of the game to reinforce territories.
    //terNames is also used to reinforce current owned areas.
    private JList terAttack;//Fills up as terrritories that are able to attack
    private static final String[] terProp = {"A-bombing site", "'A'ir-defense", "AA-testing",
      "A hint", "A-field", "'A'ir Force", "A-prep", "A-landing"};
    private static final Color[] terColor = {Color.RED, Color.BLUE,Color.GREEN,Color.PINK,
      Color.ORANGE,Color.MAGENTA,Color.LIGHT_GRAY, Color.YELLOW};//The use of colors is being used to test if the List is
    //responsive. Will later be taken out and replaced to highlight territories.
  
  
  
    public GamePage(){
  
      super("Risk");
      //set up the borders
  
      frame.add(east,BorderLayout.EAST);
      frame.add(west,BorderLayout.WEST);
      frame.setLayout(new BorderLayout());
  
      east.setLayout(new GridLayout(2,1));
      west.setLayout(new GridLayout(6,1));
  
      //JList
      terNames = new JList(terProp);
      terNames.setVisibleRowCount(3);
      terNames.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
      west.add(new JScrollPane(terNames));
  
      terNames.addListSelectionListener(new ListSelectionListener(){
        public void valueChanged(ListSelectionEvent event){
          getContentPane().setBackground(terColor[terNames.getSelectedIndex()]);
        }
      }
                                        );
  
  
  
      //First set the buttons. 
      //These will include the options to surrender:
      //Trade Cards
      //Draw Cards
      //Roll your attack dice
      //Roll your defense dice
  
      //JButtons
      surrender = new JButton("Surrender");
      draw = new JButton("Draw");
      attackRoll = new JButton("Attack");
      defendRoll = new JButton("Defend");
      trade = new JButton("Trade");
      main = new JButton("Main Menu");
      quit = new JButton("Quit");
      east.add(quit);
      east.add(main);
      west.add(surrender);
      west.add(draw);
      west.add(attackRoll);
      west.add(defendRoll);
      west.add(trade);
  
  
      ButtonHandler handler = new ButtonHandler();
      surrender.addActionListener(handler);
      draw.addActionListener(handler);
      attackRoll.addActionListener(handler);
      defendRoll.addActionListener(handler);
      trade.addActionListener(handler);
      main.addActionListener(handler);
      quit.addActionListener(handler);
      //End of JButtons
    }
  
    public static void main(String[]args){
      new GamePage();
    }
    //This is to handle the Buttons.
    private class ButtonHandler implements ActionListener{
  
      public void actionPerformed(ActionEvent event){
  
        if(event.getSource().equals(surrender)){
        }
        else if(event.getSource().equals(draw)){
        }
        else if(event.getSource().equals(attackRoll)){
        }
        else if(event.getSource().equals(defendRoll)){
        }
        else if(event.getSource().equals(trade)){
        }
        else if(event.getSource().equals(quit)){
          dispose();
        }
        else if(event.getSource().equals(main)){
          dispose();
          MainPage mainPage = new MainPage();
          mainPage.setDefaultCloseOperation(EXIT_ON_CLOSE);
          mainPage.setSize(900,600);
          mainPage.setVisible(true);
        }
      }
    }
  }
  </code></pre>