package windows;

import java.awt.GridLayout;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JFrame;

import tournamentRunner.Brackets;
import tournamentRunner.TournamentView;

/*
 * Represents a window to prompt which bracket to fill with Byes
 */
public class FillByeWindow extends JDialog implements ActionListener {
	private TournamentView view;
	private JButton confirm, cancel;
	private JComboBox<String> bracketOptions;
	private JCheckBox fillAll;
	
	
	public FillByeWindow(TournamentView view){
		this.view = view;
		confirm = new JButton("Confirm");
		confirm.addActionListener(this);
		cancel = new JButton("Cancel");
		cancel.addActionListener(this);
		
		String[] brackets = new String[Brackets.getNum()];
		for(int i=0;i<brackets.length;i++)
			brackets[i] = Brackets.getBracket(i).getName();
		bracketOptions = new JComboBox<String>(brackets);
		fillAll = new JCheckBox("Select All");
		fillAll.addActionListener(this);
		
		this.setLayout(new GridLayout(4,1));
		this.add(bracketOptions);
		this.add(fillAll);
		this.add(confirm);
		this.add(cancel);
		
		this.setSize(600,300);
		Toolkit tlkt = Toolkit.getDefaultToolkit();
		this.setModal(true);
		this.setResizable(false);
		this.setLocation((int)(tlkt.getScreenSize().getWidth()-this.getWidth())/2,(int)(tlkt.getScreenSize().getHeight()-this.getHeight())/2);
		this.setAlwaysOnTop(true);
		this.setVisible(true);
		this.pack();
	}
	
	public void actionPerformed(ActionEvent arg0) {
		Object source = arg0.getSource();
		if(source == fillAll){
			if(fillAll.getModel().isSelected()){
				bracketOptions.setEnabled(false);
			}
			else{
				bracketOptions.setEnabled(true);
			}
		}
		else if(source == cancel){
			dispose();
		}
		else if(source == confirm){
			dispose();
			view.addByes((String) bracketOptions.getSelectedItem(), fillAll.isSelected());
		}

	}

}

@@ -11,16 +11,83 @@
 ndows;%0A%0A
+import java.awt.GridBagConstraints;%0Aimport java.awt.GridBagLayout;%0A
 import j
@@ -98,32 +98,32 @@
 awt.GridLayout;%0A
-
 import java.awt.
@@ -347,16 +347,70 @@
 .JFrame;
+%0Aimport javax.swing.JLabel;%0Aimport javax.swing.JPanel;
 %0A%0Aimport
@@ -1236,28 +1236,326 @@
 this);%0A%09%09%0A%09%09
-this
+JPanel buttonPanel = new JPanel();%0A%09%09buttonPanel.setLayout(new GridBagLayout());%0A%09%09GridBagConstraints gCon = new GridBagConstraints();%0A%09%09gCon.gridheight = 10;%0A%09%09gCon.gridwidth = this.getWidth();%0A%09%09buttonPanel.add(confirm);%0A%09%09buttonPanel.add(cancel);%0A%09%09JPanel optionsPanel = new JPanel();%0A%09%09optionsPanel
 .setLayout(n
@@ -1565,28 +1565,81 @@
 Grid
+Bag
 Layout(
-4,1
 ));%0A%09%09
-this
+optionsPanel.add(new JLabel(%22Bracket: %22));%0A%09%09optionsPanel
 .add
@@ -1654,28 +1654,36 @@
 Options);%0A%09%09
-this
+optionsPanel
 .add(fillAll
@@ -1692,27 +1692,71 @@
 %0A%09%09this.
-add(confirm
+setLayout(new GridLayout(2,1));%0A%09%09this.add(optionsPanel
 );%0A%09%09thi
@@ -1757,28 +1757,33 @@
 %0A%09%09this.add(
-c
+buttonP
 an
-c
 el);%0A%09%09%0A%09%09th
@@ -2536,13 +2536,12 @@
 ));%0A
+
 %09%09%7D%0A
-%0A
 %09%7D%0A%0A

Update FillByeWindow.java