Package de.achim.turnier.endrunde

Source Code of de.achim.turnier.endrunde.FillEndrundenTabelle

package de.achim.turnier.endrunde;

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

import info.clearthought.layout.TableLayout;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import de.achim.turnier.utility.Begegnung;

public class EndrundenPanel extends JPanel {

  /**
   *
   */
  private static final long serialVersionUID = 1L;

  private EndrundenTabelle endTab;
  private JLabel lbSpielum ;
  private JTextField jtUhrzeit;
  private JComboBox jcGroup1 ;
  private JComboBox jcGroup2 ;
  private JTextField jtTore1 ;
 
  private JTextField jtTore2 ;
  private JButton btnOk ;

  private TableLayout tabLayout;
  private JPanel motherPanel;
 
  public EndrundenPanel(){

    tabLayout = new TableLayout();

    tabLayout.setRow(makeSize(1));
    tabLayout.setColumn(makeSize(7));

    lbSpielum = new JLabel();
    lbSpielum.setSize(20, 20);
    jtUhrzeit = new JTextField("12:00");
    jcGroup1 = new JComboBox();
    jcGroup2 = new JComboBox();
    jtTore1 = new JTextField("0");
    jtTore2 = new JTextField("0");
    btnOk = new JButton("OK");
    btnOk.addActionListener(new FillEndrundenTabelle(this));

    add(lbSpielum, "0,0");
    add(jtUhrzeit, "1,0");
    add(jcGroup1, "2,0");
    add(jcGroup2, "3,0");
    add(jtTore1, "4,0");
    add(jtTore2, "5,0");
    add(btnOk, "6,0");
  }
 
 
  /**
   * @return the uhrzeit
   */
  public JTextField getUhrzeit() {
    return jtUhrzeit;
  }


  /**
   * @param uhrzeit the uhrzeit to set
   */
  public void setUhrzeit(String uhrzeit) {
    this.jtUhrzeit.setText(uhrzeit);
  }


  /**
   * @return the jcGroup1
   */
  public JComboBox getJcGroup1() {
    return this.jcGroup1;
  }


  /**
   * @param jcGroup1 the jcGroup1 to set
   */
  public void setJcGroup1(JComboBox jcGroup1) {
    this.jcGroup1 = jcGroup1;
  }


  /**
   * @return the jcGroup2
   */
  public JComboBox getJcGroup2() {
    return this.jcGroup2;
  }


  /**
   * @param jcGroup2 the jcGroup2 to set
   */
  public void setJcGroup2(JComboBox jcGroup2) {
    this.jcGroup2 = jcGroup2;
  }


  /**
   * @return the jtTore1
   */
  public JTextField getJtTore1() {
    return this.jtTore1;
  }


  /**
   * @param jtTore1 the jtTore1 to set
   */
  public void setJtTore1(String jtTore1) {
    this.jtTore1.setText(jtTore1);
    revalidate();
  }


  /**
   * @return the jtTore2
   */
  public JTextField getJtTore2() {
    return this.jtTore2;
  }


  /**
   * @param jtTore2 the jtTore2 to set
   */
  public void setJtTore2(String jtTore2) {
    this.jtTore2.setText(jtTore2);
    revalidate();
  }


  /**
   * @param spielum the spielum to set
   */
  public void setSpielum(String spielum) {
    this.lbSpielum.setText(spielum);
    revalidate();
  }


  /**
   * @return the spielum
   */
  public JLabel getSpielum() {
    return lbSpielum;
  }


  /**
   * @param endTab the endTab to set
   */
  public void setEndTab(EndrundenTabelle endTab) {
    if(endTab != null)
      this.endTab = endTab;
  }


  /**
   * @return the endTab
   */
  public EndrundenTabelle getEndTab() {
    return this.endTab;
  }

  public JPanel getMotherPanel() {
    return this.motherPanel;
  }

  public void setMotherPanel(JPanel motherPanel) {
    this.motherPanel = motherPanel;
  }
 
  private double[] makeSize(int count){
    double [] arr = new double[count];
    for(int i = 0;i < count; i++){
      arr[i] = TableLayout.FILL;
    }
    return arr; 
  }
}

class FillEndrundenTabelle implements ActionListener {

  EndrundenErgebnis enderg = new EndrundenErgebnis();
  EndrundenPanel ep ;
  public FillEndrundenTabelle(EndrundenPanel ep){
    this.ep = ep;
  }
 
  @Override
  public void actionPerformed(ActionEvent e) {
   
    enderg.setMannschaft1((String) ep.getJcGroup1().getSelectedItem());
    enderg.setMannschaft2((String) ep.getJcGroup2().getSelectedItem());
    enderg.setTore1(new Integer(ep.getJtTore1().getText()));
    enderg.setTore2(new Integer(ep.getJtTore2().getText()));
   
    enderg.setSpielum(ep.getSpielum().getText());
   
    Begegnung bg = new Begegnung();
    bg.setMannschaft1(enderg.getMannschaft1());
    bg.setMannschaft2(enderg.getMannschaft2());
    bg.setToreMannschaft1(enderg.getTore1());
    bg.setToreMannschaft2(enderg.getTore2());
    bg.setDate(ep.getUhrzeit().getText())
    int gruppe = ((EndrundenPaarungsPanel)ep.getMotherPanel()).getGruppe();
    bg.setGruppe( String.valueOf(gruppe));
   
    ((EndrundenPaarungsPanel)ep.getMotherPanel()).getBegegnungsListe().add(bg);
   
    ep.getEndTab().addRow(enderg);
  }
 
}
TOP

Related Classes of de.achim.turnier.endrunde.FillEndrundenTabelle

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.