package javacity;

import java.sql.*;
import javax.swing.*;
import java.awt.Color;
import java.util.Timer;
import java.util.TimerTask;
import java.util.regex.Pattern;
import java.util.*;

public class Hauptmenue extends javax.swing.JFrame implements Runnable {

    java.awt.Cursor hand = new java.awt.Cursor(12);
    public String benutzername;
    String[] forum = new String[6];
    String[] thema = new String[6];
    ArrayList kollegendaten = new ArrayList();

    Timer zeit = new Timer();
    TimerTask akt = new TimerTask() {

        @Override
        public void run() {
            try {
                System.out.println("-----\nAKTUALISIEREN ---- START\n--------");
                ResultSet erg = DBS.abfrage("SELECT f.FName, t.Titel, MAX(b.Datum) AS 'Datum' FROM bs_Forum f, bs_Thema t, bs_Beitrag b WHERE b.TID = t.TID AND t.FName = f.FName GROUP BY t.TID ORDER BY Datum DESC LIMIT 0, 6");
                erg.next();
                thema[0] = erg.getString("t.Titel");
                forum[0] = erg.getString("f.FName");
                LForum1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, forum[0] + " - " + DBS.datum(erg.getTimestamp("Datum")), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 0, 10)));
                LForum1.setText(thema[0]);
                erg.next();
                thema[1] = erg.getString("t.Titel");
                forum[1] = erg.getString("f.FName");
                LForum2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, forum[1] + " - " + DBS.datum(erg.getTimestamp("Datum")), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 0, 10)));
                LForum2.setText(thema[1]);
                erg.next();
                thema[2] = erg.getString("t.Titel");
                forum[2] = erg.getString("f.FName");
                LForum3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, forum[2] + " - " + DBS.datum(erg.getTimestamp("Datum")), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 0, 10)));
                LForum3.setText(thema[2]);
                erg.next();
                thema[3] = erg.getString("t.Titel");
                forum[3] = erg.getString("f.FName");
                LForum4.setBorder(javax.swing.BorderFactory.createTitledBorder(null, forum[3] + " - " + DBS.datum(erg.getTimestamp("Datum")), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 0, 10)));
                LForum4.setText(thema[3]);
                erg.next();
                thema[4] = erg.getString("t.Titel");
                forum[4] = erg.getString("f.FName");
                LForum5.setBorder(javax.swing.BorderFactory.createTitledBorder(null, forum[4] + " - " + DBS.datum(erg.getTimestamp("Datum")), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 0, 10)));
                LForum5.setText(thema[4]);
                erg.next();
                thema[5] = erg.getString("t.Titel");
                forum[5] = erg.getString("f.FName");
                LForum6.setBorder(javax.swing.BorderFactory.createTitledBorder(null, forum[5] + " - " + DBS.datum(erg.getTimestamp("Datum")), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 0, 10)));
                LForum6.setText(thema[5]);
            } catch (SQLException ex) {
                System.out.println("Die Themen konnten nicht aktualisiert werden!");
            }

            try {
                ResultSet erg_anzahl = DBS.abfrage("SELECT COUNT(NID) FROM bs_Nachricht WHERE EName = '" + benutzername + "' AND Gelesen = 0");
                erg_anzahl.next();
                int anzahlnachrichten = erg_anzahl.getInt(1);
                if (anzahlnachrichten == 1) {
                    LNachricht2.setVisible(false);
                } else if (anzahlnachrichten == 0) {
                    LNachricht1.setVisible(false);
                } else {
                    LNachricht1.setVisible(true);
                    LNachricht2.setVisible(true);
                }
                ResultSet erg = DBS.abfrage("SELECT Titel, Sendezeit, SName FROM bs_Nachricht WHERE EName = '" + benutzername + "' AND Gelesen = 0 ORDER BY Sendezeit DESC LIMIT 0,2");
                erg.next();
                LNachricht1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, erg.getString("SName") + " - " + DBS.datum(erg.getTimestamp("Sendezeit")), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 0, 10)));
                LNachricht1.setText(erg.getString("Titel"));
                erg.next();
                LNachricht2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, erg.getString("SName") + " - " + DBS.datum(erg.getTimestamp("Sendezeit")), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 0, 10)));
                LNachricht2.setText(erg.getString("Titel"));
            } catch (SQLException ex) {
                System.out.println("Nachrichten konnten nicht aktualisiert werden!");
            }

            DefaultListModel ModellKollegenListe = new DefaultListModel();
            kollegendaten.clear();
            kollegendaten.add("Kollegen...");
            String[] kollegendaten1 = DBS.sqlarray("Name2", "Kollege", "Name1 = '" + benutzername + "'")
                    , kollegendaten2 = DBS.sqlarray("Name1", "Kollege", "Name2 = '" + benutzername + "'");
            for (int i = 0; i < kollegendaten1.length; i++) {
                ModellKollegenListe.addElement(kollegendaten1[i]);
                if (kollegendaten1[i] != null) {
                    kollegendaten.add(kollegendaten1[i]);
                }
            }
            for (int i = 0; i < kollegendaten2.length; i++) {
                ModellKollegenListe.addElement(kollegendaten2[i]);
                if (kollegendaten2[i] != null) {
                    kollegendaten.add(kollegendaten2[i]);
                }
            }

            String[] nachrichten = DBS.sqlarray("Titel", "Nachricht", "EName = '" + benutzername + "'");
            DefaultListModel ModellNachrichtenListe = new DefaultListModel();
            for (int i = 0; i < nachrichten.length; i++) {
                ModellNachrichtenListe.addElement(nachrichten[i]);
            }
            Liste_Kollegen.setModel(ModellKollegenListe);
            fNachrichten.Liste_Nachrichten.setModel(ModellNachrichtenListe);
            fNachrichten.kollegendaten = kollegendaten;

            System.out.println("--------\nAKTUALISIEREN --- ENDE\n-----");
        }


    };
    Forum fForum = new Forum();
    Nachrichten fNachrichten = new Nachrichten();
    Programme fProgramme = new Programme();
    JFrame achtung = new JFrame("ACHTUNG");

    public Hauptmenue() {
        initComponents();
    }

    public void run() {
        zeit.schedule(akt, 0, 15000);
        Lsicherheit.setVisible(true);
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel5 = new javax.swing.JLabel();
        jPasswordField2 = new javax.swing.JPasswordField();
        Lueberschrift = new javax.swing.JLabel();
        Lneues = new javax.swing.JLabel();
        Pdeinedaten = new javax.swing.JPanel();
        Lerneut = new javax.swing.JLabel();
        Lsicherheit = new javax.swing.JLabel();
        TFneuespasswort = new javax.swing.JPasswordField();
        TFaltespasswort = new javax.swing.JPasswordField();
        Ldeinedaten = new javax.swing.JLabel();
        Laltespasswort = new javax.swing.JLabel();
        TFerneut = new javax.swing.JPasswordField();
        LneuesPasswort = new javax.swing.JLabel();
        Banpassen = new javax.swing.JButton();
        Pforum = new javax.swing.JPanel();
        Lforum = new javax.swing.JLabel();
        Bforum = new javax.swing.JButton();
        LForum1 = new javax.swing.JLabel();
        LForum2 = new javax.swing.JLabel();
        LForum3 = new javax.swing.JLabel();
        LForum4 = new javax.swing.JLabel();
        LForum5 = new javax.swing.JLabel();
        LForum6 = new javax.swing.JLabel();
        Pnachrichten = new javax.swing.JPanel();
        Lnachrichten = new javax.swing.JLabel();
        Bnachrichtsenden = new javax.swing.JButton();
        LNachricht1 = new javax.swing.JLabel();
        LNachricht2 = new javax.swing.JLabel();
        Pprogramme = new javax.swing.JPanel();
        Lprogramme = new javax.swing.JLabel();
        Bprogramme = new javax.swing.JButton();
        Bneuesprogramm = new javax.swing.JButton();
        Bbeenden = new javax.swing.JButton();
        Pkollegen = new javax.swing.JPanel();
        Lkollegen = new javax.swing.JLabel();
        SPkollegen = new javax.swing.JScrollPane();
        Liste_Kollegen = new javax.swing.JList();
        Bhinzufuegen = new javax.swing.JButton();
        TFhinzufuegen = new javax.swing.JTextField();
        Bentfernen = new javax.swing.JButton();

        jLabel5.setText("jLabel5");

        jPasswordField2.setText("jPasswordField2");

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        setTitle("JavaCity - Hauptmenü");
        setForeground(java.awt.Color.lightGray);
        setResizable(false);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowActivated(java.awt.event.WindowEvent evt) {
                formWindowActivated(evt);
            }
        });

        Lueberschrift.setFont(new java.awt.Font("Perpetua", 1, 48));
        Lueberschrift.setText("JavaCity");

        Lneues.setFont(new java.awt.Font("Perpetua", 1, 24));
        Lneues.setText("Neues:");

        Lerneut.setText("erneut:");

        Lsicherheit.setText("Unsicher");

        Ldeinedaten.setFont(new java.awt.Font("Perpetua", 1, 18));
        Ldeinedaten.setText("Deine Daten:");

        Laltespasswort.setText("Altes Passwort:");

        LneuesPasswort.setText("Neues Passwort:");

        Banpassen.setText("Passwortsicherheit prüfen");
        Banpassen.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                BanpassenMouseClicked(evt);
            }
        });

        javax.swing.GroupLayout PdeinedatenLayout = new javax.swing.GroupLayout(Pdeinedaten);
        Pdeinedaten.setLayout(PdeinedatenLayout);
        PdeinedatenLayout.setHorizontalGroup(
            PdeinedatenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PdeinedatenLayout.createSequentialGroup()
                .addGroup(PdeinedatenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(PdeinedatenLayout.createSequentialGroup()
                        .addGap(69, 69, 69)
                        .addComponent(Ldeinedaten))
                    .addGroup(PdeinedatenLayout.createSequentialGroup()
                        .addGap(21, 21, 21)
                        .addGroup(PdeinedatenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(PdeinedatenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addGroup(PdeinedatenLayout.createSequentialGroup()
                                    .addComponent(Laltespasswort)
                                    .addGap(17, 17, 17))
                                .addGroup(PdeinedatenLayout.createSequentialGroup()
                                    .addGroup(PdeinedatenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                        .addComponent(Lerneut)
                                        .addComponent(LneuesPasswort))
                                    .addGap(18, 18, 18)))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, PdeinedatenLayout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(Lsicherheit)
                                .addGap(29, 29, 29)))
                        .addGroup(PdeinedatenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(Banpassen)
                            .addComponent(TFerneut)
                            .addComponent(TFneuespasswort)
                            .addGroup(PdeinedatenLayout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(TFaltespasswort, javax.swing.GroupLayout.DEFAULT_SIZE, 130, Short.MAX_VALUE)))))
                .addContainerGap(31, Short.MAX_VALUE))
        );
        PdeinedatenLayout.setVerticalGroup(
            PdeinedatenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PdeinedatenLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(Ldeinedaten)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(PdeinedatenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(TFaltespasswort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(Laltespasswort))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(PdeinedatenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(TFneuespasswort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(LneuesPasswort))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(PdeinedatenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(TFerneut, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(Lerneut))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(PdeinedatenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(Banpassen)
                    .addComponent(Lsicherheit))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        Lforum.setFont(new java.awt.Font("Perpetua", 1, 18));
        Lforum.setText("Neue Beiträge:");

        Bforum.setText("Zum Forum");
        Bforum.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                BforumMouseClicked(evt);
            }
        });

        LForum1.setText("Hallo Welt!");
        LForum1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "12:03:54 am 13.04.2008", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 0, 10))); // NOI18N
        LForum1.setCursor(hand);
        LForum1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                LForum1MouseClicked(evt);
            }
        });

        LForum2.setText("Hallo Welt!");
        LForum2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Allgemeines", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 0, 10))); // NOI18N
        LForum2.setCursor(hand);
        LForum2.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                LForum2MouseClicked(evt);
            }
        });

        LForum3.setText("Hallo Welt!");
        LForum3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Allgemeines", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 0, 10))); // NOI18N
        LForum3.setCursor(hand);
        LForum3.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                LForum3MouseClicked(evt);
            }
        });

        LForum4.setText("Hallo Welt!");
        LForum4.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Allgemeines", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 0, 10))); // NOI18N
        LForum4.setCursor(hand);
        LForum4.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                LForum4MouseClicked(evt);
            }
        });

        LForum5.setText("Hallo Welt!");
        LForum5.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Allgemeines", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 0, 10))); // NOI18N
        LForum5.setCursor(hand);
        LForum5.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                LForum5MouseClicked(evt);
            }
        });

        LForum6.setText("Hallo Welt!");
        LForum6.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Allgemeines", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 0, 10))); // NOI18N
        LForum6.setCursor(hand);
        LForum6.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                LForum6MouseClicked(evt);
            }
        });

        javax.swing.GroupLayout PforumLayout = new javax.swing.GroupLayout(Pforum);
        Pforum.setLayout(PforumLayout);
        PforumLayout.setHorizontalGroup(
            PforumLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PforumLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(PforumLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(LForum1, javax.swing.GroupLayout.DEFAULT_SIZE, 270, Short.MAX_VALUE)
                    .addComponent(Bforum, javax.swing.GroupLayout.DEFAULT_SIZE, 270, Short.MAX_VALUE)
                    .addComponent(Lforum)
                    .addComponent(LForum2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 270, Short.MAX_VALUE)
                    .addComponent(LForum3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 270, Short.MAX_VALUE)
                    .addComponent(LForum4, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 270, Short.MAX_VALUE)
                    .addComponent(LForum5, javax.swing.GroupLayout.DEFAULT_SIZE, 270, Short.MAX_VALUE)
                    .addComponent(LForum6, javax.swing.GroupLayout.DEFAULT_SIZE, 270, Short.MAX_VALUE))
                .addContainerGap())
        );
        PforumLayout.setVerticalGroup(
            PforumLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, PforumLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(Lforum)
                .addGap(18, 18, 18)
                .addComponent(LForum1, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(LForum2, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(LForum3, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(LForum4, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(LForum5, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(LForum6, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(Bforum)
                .addContainerGap())
        );

        Lnachrichten.setFont(new java.awt.Font("Perpetua", 1, 18));
        Lnachrichten.setText("Nachrichten:");

        Bnachrichtsenden.setText("Nachrichtenübersicht");
        Bnachrichtsenden.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                BnachrichtsendenMouseClicked(evt);
            }
        });

        LNachricht1.setText("Hallo Welt!");
        LNachricht1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "12:03:54 am 13.04.2008", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 0, 10))); // NOI18N
        LForum1.setCursor(hand);
        LNachricht1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                LNachricht1MouseClicked(evt);
            }
        });

        LNachricht2.setText("Hallo Welt!");
        LNachricht2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "12:03:54 am 13.04.2008", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 0, 10))); // NOI18N
        LForum1.setCursor(hand);
        LNachricht2.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                LNachricht2MouseClicked(evt);
            }
        });

        javax.swing.GroupLayout PnachrichtenLayout = new javax.swing.GroupLayout(Pnachrichten);
        Pnachrichten.setLayout(PnachrichtenLayout);
        PnachrichtenLayout.setHorizontalGroup(
            PnachrichtenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PnachrichtenLayout.createSequentialGroup()
                .addGroup(PnachrichtenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(PnachrichtenLayout.createSequentialGroup()
                        .addGap(23, 23, 23)
                        .addComponent(Lnachrichten)
                        .addGap(18, 18, 18)
                        .addComponent(Bnachrichtsenden))
                    .addGroup(PnachrichtenLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(LNachricht1, javax.swing.GroupLayout.DEFAULT_SIZE, 306, Short.MAX_VALUE))
                    .addGroup(PnachrichtenLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(LNachricht2, javax.swing.GroupLayout.DEFAULT_SIZE, 306, Short.MAX_VALUE)))
                .addContainerGap())
        );
        PnachrichtenLayout.setVerticalGroup(
            PnachrichtenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PnachrichtenLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(PnachrichtenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(Lnachrichten)
                    .addComponent(Bnachrichtsenden))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(LNachricht1, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(LNachricht2, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(14, Short.MAX_VALUE))
        );

        Lprogramme.setFont(new java.awt.Font("Perpetua", 1, 18));
        Lprogramme.setText("Programme:");

        Bprogramme.setText("Zu den Programmen");
        Bprogramme.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                BprogrammeMouseClicked(evt);
            }
        });

        Bneuesprogramm.setText("Neues Programm veröffentlichen");

        javax.swing.GroupLayout PprogrammeLayout = new javax.swing.GroupLayout(Pprogramme);
        Pprogramme.setLayout(PprogrammeLayout);
        PprogrammeLayout.setHorizontalGroup(
            PprogrammeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PprogrammeLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(PprogrammeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(Lprogramme)
                    .addComponent(Bneuesprogramm)
                    .addComponent(Bprogramme, javax.swing.GroupLayout.DEFAULT_SIZE, 198, Short.MAX_VALUE))
                .addContainerGap())
        );
        PprogrammeLayout.setVerticalGroup(
            PprogrammeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PprogrammeLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(Lprogramme)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 330, Short.MAX_VALUE)
                .addComponent(Bprogramme)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(Bneuesprogramm)
                .addContainerGap())
        );

        Bbeenden.setForeground(new java.awt.Color(255, 255, 255));
        Bbeenden.setText("X");
        Bbeenden.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                BbeendenMouseClicked(evt);
            }
        });

        Lkollegen.setFont(new java.awt.Font("Perpetua", 1, 18));
        Lkollegen.setText("Kollegen:");

        Liste_Kollegen.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        SPkollegen.setViewportView(Liste_Kollegen);

        Bhinzufuegen.setText("Hinzufügen");
        Bhinzufuegen.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                BhinzufuegenMouseClicked(evt);
            }
        });

        Bentfernen.setText("Entfernen");
        Bentfernen.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                BentfernenMouseClicked(evt);
            }
        });

        javax.swing.GroupLayout PkollegenLayout = new javax.swing.GroupLayout(Pkollegen);
        Pkollegen.setLayout(PkollegenLayout);
        PkollegenLayout.setHorizontalGroup(
            PkollegenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PkollegenLayout.createSequentialGroup()
                .addGroup(PkollegenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(PkollegenLayout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(PkollegenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(TFhinzufuegen, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(SPkollegen, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 132, Short.MAX_VALUE))
                        .addGap(18, 18, 18)
                        .addGroup(PkollegenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(Bhinzufuegen, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(Bentfernen, javax.swing.GroupLayout.DEFAULT_SIZE, 103, Short.MAX_VALUE)))
                    .addGroup(PkollegenLayout.createSequentialGroup()
                        .addGap(25, 25, 25)
                        .addComponent(Lkollegen)))
                .addContainerGap(65, Short.MAX_VALUE))
        );
        PkollegenLayout.setVerticalGroup(
            PkollegenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PkollegenLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(PkollegenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(PkollegenLayout.createSequentialGroup()
                        .addComponent(Lkollegen)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(SPkollegen, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(Bentfernen))
                .addGap(18, 18, 18)
                .addGroup(PkollegenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(TFhinzufuegen, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(Bhinzufuegen))
                .addContainerGap(18, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(91, 91, 91)
                                .addComponent(Lneues)
                                .addGap(109, 109, 109))
                            .addGroup(layout.createSequentialGroup()
                                .addContainerGap()
                                .addComponent(Pforum, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addGap(18, 18, 18)))
                        .addComponent(Pprogramme, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(96, 96, 96)
                        .addComponent(Lueberschrift)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(Pnachrichten, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(Pdeinedaten, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(Bbeenden, javax.swing.GroupLayout.Alignment.TRAILING))
                    .addComponent(Pkollegen, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(Bbeenden)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(Pdeinedaten, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(Pnachrichten, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(16, 16, 16)
                        .addComponent(Pkollegen, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addComponent(Lueberschrift)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(Lneues)
                        .addGap(21, 21, 21)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(Pforum, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(Pprogramme, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGap(13, 13, 13))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void BprogrammeMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_BprogrammeMouseClicked
        fProgramme.setVisible(true);
        fProgramme.run();
    }//GEN-LAST:event_BprogrammeMouseClicked

    private void BforumMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_BforumMouseClicked
        fForum.setVisible(true);
        fForum.forum = "";
        fForum.thema = "";
    }//GEN-LAST:event_BforumMouseClicked

    private void formWindowActivated(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowActivated
    }//GEN-LAST:event_formWindowActivated

    private void BbeendenMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_BbeendenMouseClicked
        System.exit(0);
    }//GEN-LAST:event_BbeendenMouseClicked

    private void BanpassenMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_BanpassenMouseClicked
        if (TFneuespasswort.getText().equals(TFerneut.getText())) {
            if (!istsicher) {
                Pattern Pkbuchstaben, Pgbuchstaben, Pzahlen, Psonderzeichen;
                Pzahlen = Pattern.compile("[0-9]");
                Pkbuchstaben = Pattern.compile("[a-z]");
                Pgbuchstaben = Pattern.compile("[A-Z]");
                Psonderzeichen = Pattern.compile("(Ä|Ö|Ü|ä|ü|ö|\\\\|\\@|\\€|\\[|\\]|\\<|\\>|\\||\\ß|\\~|\\²|\\³|\\^|\\°|\\?|\\{|\\})");
                int sicherheit = 0;
                for (int i = 0; i < TFneuespasswort.getText().length(); i++) {
                    if (Pkbuchstaben.matcher(TFneuespasswort.getText().substring(i, i + 1)).matches()) {
                        sicherheit = sicherheit + 1;
                    } else if (Pgbuchstaben.matcher(TFneuespasswort.getText().substring(i, i + 1)).matches()) {
                        sicherheit = sicherheit + 2;
                    } else if (Pzahlen.matcher(TFneuespasswort.getText().substring(i, i + 1)).matches()) {
                        sicherheit = sicherheit + 3;
                    } else if (Psonderzeichen.matcher(TFneuespasswort.getText().substring(i, i + 1)).matches()) {
                        sicherheit = sicherheit + 4;
                    } else {
                        sicherheit = sicherheit + 5;
                    }
                }
                istsicher = (sicherheit > 21);
                Lsicherheit.setVisible(true);
                if (istsicher) {
                    Lsicherheit.setForeground(Color.green);
                    Lsicherheit.setText("Sicher!");
                    Banpassen.setText("Passwort anpassen");
                } else {
                    Lsicherheit.setForeground(Color.red);
                    Lsicherheit.setText("Unsicher!");
                }
                System.out.println(sicherheit);
            } else {
                String altespasswort = DBS.ersterString("Passwort", "Benutzer", "Name='" + benutzername + "'");
                if (!TFaltespasswort.getText().equals(altespasswort)) {
                    JOptionPane.showMessageDialog(achtung, "Das eingegebene Passwort stimmt nicht mit ihrem Anmelde-Passwort überein!");
                    Lsicherheit.setForeground(Color.red);
                } else {
                    System.out.println("Passwort geändert");
                    DBS.abfrage("UPDATE bs_Benutzer SET Passwort = '" + TFerneut.getText() + "' WHERE Name = '" + benutzername + "'");
                    JOptionPane.showMessageDialog(achtung, "Passwort geändert!");

                    //JOptionPane blubb = new JOptionPane();

                    //blubb.setToolTipText("blubberblase");
                    //blubb.setMessage("Deinemudda");
                    //blubb.setVisible(true);
                }
            }
        } else {
            JOptionPane.showMessageDialog(achtung, "Die neu eingegebenen Passwört stimmen nicht überein!");
            Lsicherheit.setForeground(Color.red);
        }
        if (TFaltespasswort.getText().trim().equals("")) {
        }
    }//GEN-LAST:event_BanpassenMouseClicked

    private void LForum1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_LForum1MouseClicked
        fForum.setVisible(true);
        fForum.forum = forum[0];
        fForum.thema = thema[0];
    }//GEN-LAST:event_LForum1MouseClicked

    private void LForum2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_LForum2MouseClicked
        fForum.setVisible(true);
        fForum.forum = forum[1];
        fForum.thema = thema[1];
    }//GEN-LAST:event_LForum2MouseClicked

    private void LForum3MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_LForum3MouseClicked
        fForum.setVisible(true);
        fForum.forum = forum[2];
        fForum.thema = thema[2];
    }//GEN-LAST:event_LForum3MouseClicked

    private void LForum4MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_LForum4MouseClicked
        fForum.setVisible(true);
        fForum.forum = forum[3];
        fForum.thema = thema[3];
    }//GEN-LAST:event_LForum4MouseClicked

    private void LForum5MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_LForum5MouseClicked
        fForum.setVisible(true);
        fForum.forum = forum[4];
        fForum.thema = thema[4];
    }//GEN-LAST:event_LForum5MouseClicked

    private void LForum6MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_LForum6MouseClicked
        fForum.setVisible(true);
        fForum.forum = forum[5];
        fForum.thema = thema[5];
    }//GEN-LAST:event_LForum6MouseClicked

    private void BnachrichtsendenMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_BnachrichtsendenMouseClicked
        fNachrichten.setVisible(true);
        fNachrichten.benutzername = benutzername;
    }//GEN-LAST:event_BnachrichtsendenMouseClicked

    private void LNachricht1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_LNachricht1MouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_LNachricht1MouseClicked

    private void LNachricht2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_LNachricht2MouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_LNachricht2MouseClicked

    private void BhinzufuegenMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_BhinzufuegenMouseClicked

    }//GEN-LAST:event_BhinzufuegenMouseClicked

    private void BentfernenMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_BentfernenMouseClicked
        String markierterKollege = Liste_Kollegen.getModel().getElementAt(Liste_Kollegen.getSelectedIndex()).toString();
        DBS.abfrage("DELETE FROM bs_Kollege WHERE (Name1 = '" + benutzername + "' AND Name2 = '" + markierterKollege + "') OR (Name1 = '" + markierterKollege + "' AND Name2 = '"+ benutzername +"')");
    }//GEN-LAST:event_BentfernenMouseClicked

    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new Hauptmenue().setVisible(true);
            }
        });
    }
    Boolean istsicher = false;
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton Banpassen;
    private javax.swing.JButton Bbeenden;
    private javax.swing.JButton Bentfernen;
    private javax.swing.JButton Bforum;
    private javax.swing.JButton Bhinzufuegen;
    private javax.swing.JButton Bnachrichtsenden;
    private javax.swing.JButton Bneuesprogramm;
    private javax.swing.JButton Bprogramme;
    private javax.swing.JLabel LForum1;
    private javax.swing.JLabel LForum2;
    private javax.swing.JLabel LForum3;
    private javax.swing.JLabel LForum4;
    private javax.swing.JLabel LForum5;
    private javax.swing.JLabel LForum6;
    private javax.swing.JLabel LNachricht1;
    private javax.swing.JLabel LNachricht2;
    private javax.swing.JLabel Laltespasswort;
    private javax.swing.JLabel Ldeinedaten;
    private javax.swing.JLabel Lerneut;
    private javax.swing.JLabel Lforum;
    private javax.swing.JList Liste_Kollegen;
    private javax.swing.JLabel Lkollegen;
    private javax.swing.JLabel Lnachrichten;
    private javax.swing.JLabel Lneues;
    private javax.swing.JLabel LneuesPasswort;
    private javax.swing.JLabel Lprogramme;
    private javax.swing.JLabel Lsicherheit;
    private javax.swing.JLabel Lueberschrift;
    private javax.swing.JPanel Pdeinedaten;
    private javax.swing.JPanel Pforum;
    private javax.swing.JPanel Pkollegen;
    private javax.swing.JPanel Pnachrichten;
    private javax.swing.JPanel Pprogramme;
    private javax.swing.JScrollPane SPkollegen;
    private javax.swing.JPasswordField TFaltespasswort;
    private javax.swing.JPasswordField TFerneut;
    private javax.swing.JTextField TFhinzufuegen;
    private javax.swing.JPasswordField TFneuespasswort;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JPasswordField jPasswordField2;
    // End of variables declaration//GEN-END:variables
}
