package paketFensterklassen;
import java.awt.BorderLayout;
import javax.swing.*;
import java.util.*;
import paketFachklassen.*;
import javax.swing.JButton;
public class Teamfenster extends JFrame {
private JPanel jContentPane = null;
private JButton jButton = null;
private JComboBox jComboBox = null;
private DB_Zugriff dbz;
private JComboBox jComboBox1 = null;
private JLabel jLabel = null;
private JLabel jLabel1 = null;
private JLabel jLabel2 = null;
private JButton jButton1 = null;
private JTextField jTextField = null;
public Teamfenster(DB_Zugriff dbz) {
super();
initialize();
this.dbz = dbz;
}
public void updateCombobox(JComboBox jcb){
dbz.zugriffOeffnen();
Vector<Spieler> spielerListe = dbz.getSpieler();
dbz.zugriffSchliessen();
jcb.setModel(new DefaultComboBoxModel(spielerListe));
}
private void initialize() {
this.setSize(344, 234);
this.setResizable(false);
this.setContentPane(getJContentPane());
this.setTitle("Team erstellen");
}
private JPanel getJContentPane() {
if (jContentPane == null) {
jLabel2 = new JLabel();
jLabel2.setBounds(new java.awt.Rectangle(30,80,67,16));
jLabel2.setText("Teamname:");
jLabel1 = new JLabel();
jLabel1.setBounds(new java.awt.Rectangle(224,12,50,22));
jLabel1.setText("Spieler2:");
jLabel = new JLabel();
jLabel.setBounds(new java.awt.Rectangle(58,11,50,22));
jLabel.setText("Spieler1:");
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.add(getJButton(), null);
jContentPane.add(getJComboBox(), null);
jContentPane.add(getJComboBox1(), null);
jContentPane.add(jLabel, null);
jContentPane.add(jLabel1, null);
jContentPane.add(jLabel2, null);
jContentPane.add(getJButton1(), null);
jContentPane.add(getJTextField(), null);
}
return jContentPane;
}
private JButton getJButton() {
if (jButton == null) {
jButton = new JButton();
jButton.setBounds(new java.awt.Rectangle(10,165,90,26));
jButton.setText("Schließen");
jButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
setVisible(false);
}
});
}
return jButton;
}
private JComboBox getJComboBox() {
if (jComboBox == null) {
jComboBox = new JComboBox();
jComboBox.setBounds(new java.awt.Rectangle(20,39,141,19));
}
return jComboBox;
}
private JComboBox getJComboBox1() {
if (jComboBox1 == null) {
jComboBox1 = new JComboBox();
jComboBox1.setBounds(new java.awt.Rectangle(182,39,141,19));
jComboBox1.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(java.awt.event.ItemEvent e) {
updateCombobox(jComboBox);
jComboBox.removeItem(jComboBox1.getSelectedItem());
}
});
}
return jComboBox1;
}
private JButton getJButton1() {
if (jButton1 == null) {
jButton1 = new JButton();
jButton1.setBounds(new java.awt.Rectangle(121,112,90,26));
jButton1.setText("Erstellen");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
if(jTextField.getText().equals("")){
JOptionPane.showMessageDialog(null,"Geben Sie einen Teamnamen ein.","Fehler!",JOptionPane.ERROR_MESSAGE);
}else{
dbz.zugriffOeffnen();
//dbz.teamErstellen(dbz.neuerPrimTeam(),jComboBox.getSelectedItem(),jComboBox1.getSelectedItem(), jTextField.getText());
dbz.zugriffSchliessen();
JOptionPane.showMessageDialog(null,"Das Team wurde erstellt.","Erfolg!",JOptionPane.INFORMATION_MESSAGE);
updateCombobox(jComboBox);
updateCombobox(jComboBox1);
}
}
});
}
return jButton1;
}
private JTextField getJTextField() {
if (jTextField == null) {
jTextField = new JTextField();
jTextField.setBounds(new java.awt.Rectangle(113,80,120,19));
}
return jTextField;
}
public JComboBox getJCB1(){
return jComboBox1;
}
public JComboBox getJCB(){
return jComboBox;
}
}