package Notenberechner;
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.WindowConstants;
public class Fenster {
public static JTextField tf_schulz[] = new JTextField[40];
public static JTextField tf_exen[] = new JTextField[40];
public static JTextField tf_mündlich[] = new JTextField[40];
public static JTextField tf_referat[] = new JTextField[40];
public static JTextField tf_note[] = new JTextField[10];
public static JLabel lb_fach[] = new JLabel[10];
public static JLabel lb_note[] = new JLabel[5];
public static JButton bt_close = new JButton();
public static JButton bt_delete = new JButton();
public static JFrame frame = new JFrame("Notenberechner");
public static String str_pfad = "D:\\Programm Files\\Programmieren\\eclipse\\Admin\\";
Fenster(){
int x_pos = 0;
int y_pos = 0;
int Y_POS = 50;
int höhe = 0;
int breite = 0;
int zähler = 0;
int tmp_x = 0;
int x_note[]= new int[5];
KeyListener key = new KeyListener(){
public void keyPressed(KeyEvent arg0) {}
public void keyReleased(KeyEvent arg0) {
Berechner rechner = new Berechner();
rechner.leeren();
rechner.exen();
rechner.mündlich();
rechner.schulz();
rechner.referate();
rechner.ausgabe();
}
public void keyTyped(KeyEvent arg0) {}
};
/* Schleife zum Anlegen der Textfelder */
for(int index = 0; index < 40; index++){
tf_schulz[index] = new JTextField();
tf_exen[index] = new JTextField();
tf_mündlich[index] = new JTextField();
tf_referat[index] = new JTextField();
tf_schulz[index].addKeyListener(key);
tf_exen[index].addKeyListener(key);
tf_mündlich[index].addKeyListener(key);
tf_referat[index].addKeyListener(key);
}
for(int index = 0; index < 10; index++){
tf_note[index] = new JTextField();
lb_fach[index] = new JLabel();
}
for(int index = 0; index < 5; index++){
lb_note[index] = new JLabel();
}
/* Layout des Frames */
frame.setLayout(null);
/* Layout der Labels */
x_pos = 10;
y_pos = Y_POS;
höhe = 20;
breite = 60;
for(int index = 0; index < 10; index++){
lb_fach[index].setBounds(x_pos, y_pos, breite, höhe);
y_pos = y_pos + höhe + 5;
}
/* Layout der Exen */
zähler = 0;
tmp_x = x_pos + 60;
x_pos = tmp_x + 20;
x_note[0] = x_pos;
y_pos = Y_POS;
höhe = 20;
breite = 20;
for(int index = 0; index < 40; index++){
if(zähler == 4){
y_pos = y_pos + höhe + 5;
x_pos = tmp_x + 20;
zähler = 0;
}
tf_exen[index].setBounds(x_pos, y_pos, breite, höhe);
x_pos = x_pos + breite + 5;
zähler++;
}
/* Layout der Mündlichen */
zähler = 0;
tmp_x = x_pos;
x_pos = tmp_x + 20;
x_note[1] = x_pos;
y_pos = Y_POS;
for(int index = 0; index < 40; index++){
if(zähler == 4){
y_pos = y_pos + höhe + 5;
x_pos = tmp_x + 20;
zähler = 0;
}
tf_mündlich[index].setBounds(x_pos, y_pos, breite, höhe);
x_pos = x_pos + breite + 5;
zähler++;
}
/* Layout der Schulaufgaben */
zähler = 0;
tmp_x = x_pos;
x_pos = tmp_x + 20;
x_note[2] = x_pos;
y_pos = Y_POS;
for(int index = 0; index < 40; index++){
if(zähler == 4){
y_pos = y_pos + höhe + 5;
x_pos = tmp_x + 20;
zähler = 0;
}
tf_schulz[index].setBounds(x_pos, y_pos, breite, höhe);
x_pos = x_pos + breite + 5;
zähler++;
}
/* Layout der Referate */
zähler = 0;
tmp_x = x_pos;
x_pos = tmp_x + 20;
x_note[3] = x_pos;
y_pos = Y_POS;
for(int index = 0; index < 40; index++){
if(zähler == 4){
y_pos = y_pos + höhe + 5;
x_pos = tmp_x + 20;
zähler = 0;
}
tf_referat[index].setBounds(x_pos, y_pos, breite, höhe);
x_pos = x_pos + breite + 5;
zähler++;
}
/* Layout der Durchschnitte */
tmp_x = x_pos;
x_pos = tmp_x + 20;
x_note[4] = x_pos;
y_pos = Y_POS;
for(int index = 0; index < 10; index++){
tf_note[index].setBounds(x_pos, y_pos, breite, höhe);
y_pos = y_pos + höhe + 5;
}
/* Layout der Noten Bezeichnungen */
y_pos = 25;
breite = 85;
for(int index = 0; index < 5; index++){
lb_note[index].setBounds(x_note[index], y_pos, breite, höhe);
}
/* Layout der Buttons */
bt_close.setBounds(584, 0, 16, 16);
bt_delete.setBounds(564, 0, 16, 16);
/* Schleife zum hinzufügen der Komponenten */
for(int index = 0; index < 40; index++){
frame.add(tf_schulz[index]);
frame.add(tf_exen[index]);
frame.add(tf_mündlich[index]);
frame.add(tf_referat[index]);
}
for(int index = 0; index < 10; index++){
frame.add(tf_note[index]);
frame.add(lb_fach[index]);
}
for(int index = 0; index < 5; index++){
frame.add(lb_note[index]);
}
frame.add(bt_close);
frame.add(bt_delete);
/* Eigenschaften des Frames */
Color color = new Color(0, 153, 255);
frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
frame.setResizable(false);
frame.setUndecorated(true);
frame.getContentPane().setBackground(color);
frame.setSize(600, 300);
frame.setAlwaysOnTop(false);
frame.setLocation(550, 0);
}
/* Funktion zum Anzeigen des Fensters */
public static void anzeigen(boolean bool){
frame.setVisible(bool);
}
}
/* Fächer und dazugehörigen Noten
* 00. AnPr 00 - 03
* 01. VersNe 04 - 07
* 02. VersÖf 08 - 11
* 03. VersWi 12 - 15
* 04. BWR 16 - 19
* 05. Sozi 20 - 23
* 06. Englisch 24 - 27
* 07. Deutsch 28 - 31
* 08. Sport 32 - 35
* 09. Ethik 36 - 39
*/