package view;
import javax.swing.JPanel;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import javax.swing.JLabel;
import java.awt.Insets;
import javax.swing.JButton;
import javax.swing.JTextField;
import model.Contestant;
import controller.Control;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class Panel_Login extends JPanel implements ActionListener{
private JTextField textField_UserName;
private JTextField textField_Passwd;
private JTextField textField_JudgesCount;
/**
* Create the panel.
*/
public Panel_Login() {
GridBagLayout gridBagLayout = new GridBagLayout();
gridBagLayout.columnWidths = new int[]{0, 0};
gridBagLayout.rowHeights = new int[]{0, 0};
gridBagLayout.columnWeights = new double[]{1.0, Double.MIN_VALUE};
gridBagLayout.rowWeights = new double[]{1.0, Double.MIN_VALUE};
setLayout(gridBagLayout);
JPanel panel = new JPanel();
GridBagConstraints gbc_panel = new GridBagConstraints();
gbc_panel.gridx = 0;
gbc_panel.gridy = 0;
add(panel, gbc_panel);
GridBagLayout gbl_panel = new GridBagLayout();
gbl_panel.columnWidths = new int[]{0, 0, 0, 0};
gbl_panel.rowHeights = new int[]{0, 0, 0, 0};
gbl_panel.columnWeights = new double[]{0.0, 1.0, 0.0, Double.MIN_VALUE};
gbl_panel.rowWeights = new double[]{0.0, 0.0, 0.0, Double.MIN_VALUE};
panel.setLayout(gbl_panel);
JLabel label = new JLabel("\u9009\u624B\u59D3\u540D\uFF1A");
GridBagConstraints gbc_label = new GridBagConstraints();
gbc_label.anchor = GridBagConstraints.EAST;
gbc_label.insets = new Insets(0, 0, 5, 5);
gbc_label.gridx = 0;
gbc_label.gridy = 0;
panel.add(label, gbc_label);
textField_UserName = new JTextField();
GridBagConstraints gbc_textField_UserName = new GridBagConstraints();
gbc_textField_UserName.insets = new Insets(0, 0, 5, 5);
gbc_textField_UserName.gridx = 1;
gbc_textField_UserName.gridy = 0;
panel.add(textField_UserName, gbc_textField_UserName);
textField_UserName.setColumns(10);
JButton button = new JButton("\u786E\u5B9A");
button.addActionListener(this);
GridBagConstraints gbc_button = new GridBagConstraints();
gbc_button.insets = new Insets(0, 0, 5, 0);
gbc_button.gridx = 2;
gbc_button.gridy = 0;
panel.add(button, gbc_button);
JLabel label_1 = new JLabel("\u9009\u624B\u5BC6\u7801\uFF1A");
GridBagConstraints gbc_label_1 = new GridBagConstraints();
gbc_label_1.anchor = GridBagConstraints.EAST;
gbc_label_1.insets = new Insets(0, 0, 5, 5);
gbc_label_1.gridx = 0;
gbc_label_1.gridy = 1;
panel.add(label_1, gbc_label_1);
textField_Passwd = new JTextField();
GridBagConstraints gbc_textField_Passwd = new GridBagConstraints();
gbc_textField_Passwd.insets = new Insets(0, 0, 5, 5);
gbc_textField_Passwd.gridx = 1;
gbc_textField_Passwd.gridy = 1;
panel.add(textField_Passwd, gbc_textField_Passwd);
textField_Passwd.setColumns(10);
JButton button_2 = new JButton("\u6E05\u7A7A");
GridBagConstraints gbc_button_2 = new GridBagConstraints();
gbc_button_2.insets = new Insets(0, 0, 5, 0);
gbc_button_2.gridx = 2;
gbc_button_2.gridy = 1;
panel.add(button_2, gbc_button_2);
JLabel label_2 = new JLabel("\u8BC4\u59D4\u6570\u91CF\uFF1A");
GridBagConstraints gbc_label_2 = new GridBagConstraints();
gbc_label_2.anchor = GridBagConstraints.EAST;
gbc_label_2.insets = new Insets(0, 0, 0, 5);
gbc_label_2.gridx = 0;
gbc_label_2.gridy = 2;
panel.add(label_2, gbc_label_2);
textField_JudgesCount = new JTextField();
textField_JudgesCount.setColumns(10);
GridBagConstraints gbc_textField_JudgesCount = new GridBagConstraints();
gbc_textField_JudgesCount.insets = new Insets(0, 0, 0, 5);
gbc_textField_JudgesCount.fill = GridBagConstraints.HORIZONTAL;
gbc_textField_JudgesCount.gridx = 1;
gbc_textField_JudgesCount.gridy = 2;
panel.add(textField_JudgesCount, gbc_textField_JudgesCount);
JButton button_1 = new JButton("\u9000\u51FA");
GridBagConstraints gbc_button_1 = new GridBagConstraints();
gbc_button_1.gridx = 2;
gbc_button_1.gridy = 2;
panel.add(button_1, gbc_button_1);
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
String userName=textField_UserName.getText();
String passwd=textField_Passwd.getText();
int judgesCount=Integer.parseInt(textField_JudgesCount.getText());
Control.login(userName,passwd,judgesCount,this);
}
}