/*
* TurnierBaum.java
*
* Created on 28. Mai 2008, 16:48
*/
/**
*
* @author fleki
*/
public class TurnierBaum extends javax.swing.JFrame {
/** Creates new form TurnierBaum */
public TurnierBaum() {
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
team1 = new javax.swing.JTextField();
team2 = new javax.swing.JTextField();
team3 = new javax.swing.JTextField();
team4 = new javax.swing.JTextField();
team5 = new javax.swing.JTextField();
team6 = new javax.swing.JTextField();
team7 = new javax.swing.JTextField();
team8 = new javax.swing.JTextField();
teamA = new javax.swing.JLabel();
teamB = new javax.swing.JLabel();
teamC = new javax.swing.JLabel();
teamD = new javax.swing.JLabel();
teamE = new javax.swing.JLabel();
teamF = new javax.swing.JLabel();
teamG = new javax.swing.JLabel();
teamH = new javax.swing.JLabel();
btSimulieren = new javax.swing.JButton();
btAuslosung = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
team1.setText("Mannschaft 1");
team1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
team1MouseClicked(evt);
}
});
team1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
team1ActionPerformed(evt);
}
});
team2.setText("Mannschaft 2");
team2.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
team2MouseClicked(evt);
}
});
team2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
team2ActionPerformed(evt);
}
});
team3.setText("Mannschaft 3");
team3.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
team3MouseClicked(evt);
}
});
team4.setText("Mannschaft 4");
team4.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
team4MouseClicked(evt);
}
});
team5.setText("Mannschaft 5");
team6.setText("Mannschaft 6");
team7.setText("Mannschaft 7");
team8.setText("Mannschaft 8");
teamA.setText(" ");
teamB.setText(" ");
teamC.setText(" ");
teamD.setText(" ");
teamE.setText(" ");
teamF.setText(" ");
teamG.setText(" ");
teamH.setText(" ");
btSimulieren.setText("Simulieren!");
btAuslosung.setText("Auslosen!");
btAuslosung.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btAuslosungActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addComponent(team2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(teamB, javax.swing.GroupLayout.DEFAULT_SIZE, 96, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addComponent(team3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(teamC, javax.swing.GroupLayout.DEFAULT_SIZE, 96, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addComponent(team4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(teamD, javax.swing.GroupLayout.DEFAULT_SIZE, 96, Short.MAX_VALUE)))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addComponent(team5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(teamE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addComponent(team6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(teamF, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addComponent(team7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(teamG, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addComponent(team8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(teamH, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addComponent(team1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(teamA, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addGap(114, 114, 114)
.addComponent(btAuslosung)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btSimulieren)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(team1, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(teamA))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(team2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(teamB))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(team3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(teamC))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(team4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(teamD))
.addGap(38, 38, 38)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(team5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(teamE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(team6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(teamF))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(team7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(teamG))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(team8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btSimulieren)
.addComponent(btAuslosung)
.addComponent(teamH))
.addContainerGap(15, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void team1ActionPerformed(java.awt.event.ActionEvent evt) {
}
private void team2ActionPerformed(java.awt.event.ActionEvent evt) {
}
private void team1MouseClicked(java.awt.event.MouseEvent evt) {
team1.setText("");
}
private void team2MouseClicked(java.awt.event.MouseEvent evt) {
team2.setText("");
}
private void team3MouseClicked(java.awt.event.MouseEvent evt) {
team3.setText("");
}
private void team4MouseClicked(java.awt.event.MouseEvent evt) {
team4.setText("");
}
private void btAuslosungActionPerformed(java.awt.event.ActionEvent evt) {
auslosung();
btAuslosung.setVisible(false);
team1.setVisible(false);
team2.setVisible(false);
team3.setVisible(false);
team4.setVisible(false);
team5.setVisible(false);
team6.setVisible(false);
team7.setVisible(false);
team8.setVisible(false);
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new TurnierBaum().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton btAuslosung;
private javax.swing.JButton btSimulieren;
private javax.swing.JTextField team1;
private javax.swing.JTextField team2;
private javax.swing.JTextField team3;
private javax.swing.JTextField team4;
private javax.swing.JTextField team5;
private javax.swing.JTextField team6;
private javax.swing.JTextField team7;
private javax.swing.JTextField team8;
private javax.swing.JLabel teamA;
private javax.swing.JLabel teamB;
private javax.swing.JLabel teamC;
private javax.swing.JLabel teamD;
private javax.swing.JLabel teamE;
private javax.swing.JLabel teamF;
private javax.swing.JLabel teamG;
private javax.swing.JLabel teamH;
// End of variables declaration
String teamSort[] = new String[100];
String teamSorted[] = new String[100];
/** Dient zum ermitteln einer beliebig hohen Zufallszahl
*
* @param ziffer
* @return number
*/
public int random(int ziffer){
java.util.Random random = new java.util.Random(); // Erstellen eines Objektes Random
int number = random.nextInt(ziffer) +1; // Zufahlszahl von 0 bis Ziffer erstellen
return number;
}
/**
*
*/
public void auslosung(){
int x=0, i=1, a = 0;
teamSort[1]=team1.getText();
teamSort[2]=team2.getText();
teamSort[3]=team3.getText();
teamSort[4]=team4.getText();
teamSort[5]=team5.getText();
teamSort[6]=team6.getText();
teamSort[7]=team7.getText();
teamSort[8]=team8.getText();
do{
x=random(9);
if(teamSorted[x]==null){
teamSorted[x]=teamSort[i];
a ++;
}else i--;
i ++;
}while(a != 9);
teamA.setText(teamSorted[1]);
teamB.setText(teamSorted[2]);
teamC.setText(teamSorted[3]);
teamD.setText(teamSorted[4]);
teamE.setText(teamSorted[5]);
teamF.setText(teamSorted[6]);
teamG.setText(teamSorted[7]);
teamH.setText(teamSorted[8]);
}
}