/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package signatur;
//import javax.swing.JOptionPane;
//import java.io.*;
//import java.util.*;
import java.awt.Color;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import javax.swing.JFileChooser;
import java.nio.file.Path;
import javax.swing.BorderFactory;
import javax.swing.JComboBox;
import javax.swing.JTextField;
import javax.swing.border.Border;
import javax.swing.border.LineBorder;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.Document;
import static javax.swing.text.StyleConstants.Background;
/**
*
* @author david
*/
public class GUI extends javax.swing.JFrame {
/**
* Creates new form GUI
*/
public GUI() {
//setzt Startwert beim Ausführen des Programms
initComponents();
jTextFieldTel.setEnabled(false);
jTextFieldFax.setEnabled(false);
jTextAreaAusgabe.setEnabled(false);
jTextAreaAusgabe.setDisabledTextColor(Color.BLACK);
jTextFieldMuttersprache.setEnabled(false);
jTextFieldFremdsprachen.setEnabled(false);
}
//Initialisierung der ganzen Strings
String
varVorname = "", varNachname = "", varFunktion = "", varFunktionHtml = "", varFirmierung = "", varStrasze = "",
varStraszeHtml = "", varOrtPlz = "", varOrtPlzHtml = "", varTel = "", varTelStartGer = "", varTelInt = "",
varTelStartInt = "", varTelEndDefault = "", varTelEndIndiv = "", varFax = "", varFaxStart = "",
varFaxEndDefault = "", varFaxEndIndiv = "", varEmailPx = "", varEmailSx = "", varEmailKx = "",
varOrt = "", htmlFinal = "", txtFinal = "", varSprachkombi = "", varMuttersprache = "",
varFremdsprache = "", ComboBoxBereich = "";
//String a1 = "Praktikant", a2 ="Praktikantin"; //erst mal nur als Test gedacht
//Methode für Sonderzeichen/Umlaute
public String Html(String html){
html = html.replace("Ä", "Ä");
html = html.replace("ä", "ä");
html = html.replace("Ö", "Ö");
html = html.replace("ö", "ö");
html = html.replace("Ü", "Ü");
html = html.replace("ü", "ü");
html = html.replace("ß", "ß");
return html;
}
//Methode um die Email richtig zu bilden
public String eHtml(String ehtml){
ehtml = ehtml.replace("ä", "ae");
ehtml = ehtml.replace("ö", "oe");
ehtml = ehtml.replace("ü", "ue");
ehtml = ehtml.replace("ß", "sz");
return ehtml;
}
//wichtig für ComboboxVerzweigung (ausgelagert)
public String getjComboBoxFiliale(){
return "" + jComboBoxFiliale.getSelectedItem();
}
DocumentListener documentListener = new DocumentListener() {
@Override
public void changedUpdate(DocumentEvent documentEvent) {
jTextFieldVorname.setBorder(new JTextField().getBorder());
}
@Override
public void insertUpdate(DocumentEvent documentEvent) {
jTextFieldVorname.setBorder(new JTextField().getBorder());
}
@Override
public void removeUpdate(DocumentEvent documentEvent) {
jTextFieldVorname.setBorder(new JTextField().getBorder());
}
};
//JTextField jTextFieldVorname = new JTextField();
//jTextFieldVorname.getDocument().addDocumentListener(documentListener);
//jTextFieldVorname.getDocument().addDocumentListener(new documentListener());
//KeyListener keyListener = new KeyListener()
//jTextFieldVorname.getDocument().addDocumentListener(this);
public void keyTyped(KeyEvent e) {
if(!"".equals(jTextFieldVorname.getText()) || !"<Vorname>".equals(jTextFieldVorname.getText())){
jTextFieldVorname.setBorder(new JTextField().getBorder());
}
}
// JTextField tf = new JTextField();
//JTextField borderDefault = new JTextField();
//borderDefault = jTextFieldVorname.getBorder();
//JTextField borderDefault = new JTextField();
//JComboBox boxDefault = new JComboBox();
//LineBorder border = (LineBorder) borderDefault.getBorder();
//String testFunktion = "Süßigkeitenverkäufer";
//String testFunktionNeu = Html(testFunktion);
/*public void isEqualToPraktikant() {
String PraktM = "Praktikant", PraktW = "Praktikantin";
String text = jTextFieldFunktion.getText();
if(text.equals(PraktM) || text.equals(PraktW)) {
jTextFieldMuttersprache.setEnabled(true);
jTextFieldFremdsprachen.setEnabled(true);
}
else{
jTextFieldMuttersprache.setEnabled(false);
jTextFieldFremdsprachen.setEnabled(false);
}
}*/
/**
* 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.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jPanel2 = new javax.swing.JPanel();
jButton1 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
jPanel3 = new javax.swing.JPanel();
jTextFieldVorname = new javax.swing.JTextField();
jLabelVorname = new javax.swing.JLabel();
jTextFieldNachname = new javax.swing.JTextField();
jLabelNachname = new javax.swing.JLabel();
jLabelFunktion = new javax.swing.JLabel();
jTextFieldFunktion = new javax.swing.JTextField();
jComboBoxTitel = new javax.swing.JComboBox<>();
jToggleButton1 = new javax.swing.JToggleButton();
jLabel5 = new javax.swing.JLabel();
jTextFieldMuttersprache = new javax.swing.JTextField();
jLabel6 = new javax.swing.JLabel();
jTextFieldFremdsprachen = new javax.swing.JTextField();
jLabel3 = new javax.swing.JLabel();
jPanel4 = new javax.swing.JPanel();
jComboBoxFiliale = new javax.swing.JComboBox<>();
jLabel2 = new javax.swing.JLabel();
jCheckBox1 = new javax.swing.JCheckBox();
jTextFieldTel = new javax.swing.JTextField();
jCheckBox2 = new javax.swing.JCheckBox();
jTextFieldFax = new javax.swing.JTextField();
jComboBoxBereich = new javax.swing.JComboBox<>();
jButton2 = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
jTextAreaAusgabe = new javax.swing.JTextArea();
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Signatur Ersteller");
setBackground(new java.awt.Color(115, 145, 255));
jPanel2.setBackground(new java.awt.Color(233, 255, 153));
jButton1.setText("Vorschau");
jButton1.setVerifyInputWhenFocusTarget(false);
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jButton3.setText("Signatur erstellen!");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
.addGap(46, 46, 46)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(46, 46, 46)
.addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton3))
.addContainerGap())
);
jPanel3.setBackground(new java.awt.Color(229, 229, 229));
jTextFieldVorname.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextFieldVornameActionPerformed(evt);
}
});
jLabelVorname.setText("Vorname:");
jLabelNachname.setText("Nachname:");
jLabelFunktion.setText("Funktion:");
jTextFieldFunktion.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextFieldFunktionActionPerformed(evt);
}
});
jComboBoxTitel.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Titel", "B.A.", "M.A.", "B.Sc.", "M.Sc.", "Mag.", "Dipl.", "Dipl. (FH)", "Dr." }));
jComboBoxTitel.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jComboBoxTitelActionPerformed(evt);
}
});
jToggleButton1.setText("Sprachkombi");
jToggleButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jToggleButton1ActionPerformed(evt);
}
});
jLabel5.setText("Muttersprache:");
jLabel6.setText("Fremdsprachen:");
jTextFieldFremdsprachen.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextFieldFremdsprachenActionPerformed(evt);
}
});
jLabel3.setText("(z.B. Projektmanagement, Praktikant, etc.)");
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addGap(6, 6, 6)
.addComponent(jLabelVorname)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jTextFieldVorname, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(24, 24, 24)
.addComponent(jLabelNachname)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jTextFieldNachname, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 30, Short.MAX_VALUE)
.addComponent(jComboBoxTitel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel3Layout.createSequentialGroup()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addGap(6, 6, 6)
.addComponent(jLabelFunktion)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jTextFieldFunktion, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jLabel3))
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(jToggleButton1)
.addGap(24, 24, 24)
.addComponent(jLabel5)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jTextFieldMuttersprache, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(33, 33, 33)
.addComponent(jLabel6)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jTextFieldFremdsprachen, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(0, 0, Short.MAX_VALUE)))
.addContainerGap())
);
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabelVorname)
.addComponent(jTextFieldVorname, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabelNachname)
.addComponent(jTextFieldNachname, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jComboBoxTitel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(23, 23, 23)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabelFunktion)
.addComponent(jTextFieldFunktion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3))
.addGap(18, 18, 18)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jToggleButton1)
.addComponent(jLabel5)
.addComponent(jTextFieldMuttersprache, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel6)
.addComponent(jTextFieldFremdsprachen, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(19, Short.MAX_VALUE))
);
jPanel4.setBackground(new java.awt.Color(229, 229, 229));
jComboBoxFiliale.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Filiale", "Frankfurt am Main (Zentrale)", "Frankfurt am Main (Hauptwache)", "Aachen", "Augsburg", "Berlin", "Bielefeld", "Bochum", "Bonn", "Braunschweig", "Bremen", "Darmstadt", "Dortmund", "Dresden", "Duisburg", "Düsseldorf", "Essen", "Freiburg", "Friedrichshafen", "Hamburg", "Hannover", "Heilbronn", "Ingolstadt", "Kaiserslautern", "Karlsruhe", "Kassel", "Kiel", "Köln", "Leipzig", "Mainz", "Mannheim", "Mönchengladbach", "München", "Münster", "Nürnberg", "Offenbach am Main", "Regensburg", "Saarbrücken", "Schweinfurt", "Stuttgart", "Ulm", "Weil am Rhein", "Wiesbaden", "Wuppertal", "Würzburg" }));
jComboBoxFiliale.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jComboBoxFilialeActionPerformed(evt);
}
});
jLabel2.setText("Individuellen Endungen:");
jCheckBox1.setText("Tel.-Endung:");
jCheckBox1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jCheckBox1ActionPerformed(evt);
}
});
jCheckBox2.setText("Fax-Endung:");
jCheckBox2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jCheckBox2ActionPerformed(evt);
}
});
jComboBoxBereich.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Bereich", "AG", "Training", "CEF" }));
jComboBoxBereich.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jComboBoxBereichActionPerformed(evt);
}
});
jButton2.setText("jButton2");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
jPanel4.setLayout(jPanel4Layout);
jPanel4Layout.setHorizontalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addGap(18, 18, 18)
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jComboBoxBereich, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jComboBoxFiliale, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel4Layout.createSequentialGroup()
.addGap(12, 12, 12)
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addComponent(jCheckBox1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jTextFieldTel, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE))
.addGroup(jPanel4Layout.createSequentialGroup()
.addComponent(jCheckBox2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jTextFieldFax, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))))
.addContainerGap())
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton2)
.addGap(47, 47, 47))
);
jPanel4Layout.setVerticalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jComboBoxFiliale, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2)
.addComponent(jComboBoxBereich, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jCheckBox1)
.addComponent(jTextFieldTel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jCheckBox2)
.addComponent(jTextFieldFax, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 7, Short.MAX_VALUE)
.addComponent(jButton2))
);
jTextAreaAusgabe.setColumns(20);
jTextAreaAusgabe.setRows(5);
jScrollPane1.setViewportView(jTextAreaAusgabe);
jPanel1.setBackground(java.awt.Color.blue);
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
jLabel1.setForeground(new java.awt.Color(255, 255, 255));
jLabel1.setText("Version 1.0 - für Standorte in Deutschland. ");
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jScrollPane1)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 150, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
);
pack();
}// </editor-fold>
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
//leerte die TextArea bei mehrmals Klicken
jTextAreaAusgabe.setText("");
//Vorname, Nachname, Funktion
varVorname = jTextFieldVorname.getText();
varNachname = jTextFieldNachname.getText();
varFunktion = jTextFieldFunktion.getText();
//hier kommt die if-else-Verzweigung hin
//setzt Platzhalter, wenn Felder nicht ausgefüllt (nur für Vorschau-Button)
if("".equals(varVorname)){
varVorname = "<Vorname>";
}
if("".equals(varNachname)){
varNachname = "<Nachname>";
}
if("".equals(varFunktion)){
varFunktion = "<Funktion>";
}
if("".equals(varFirmierung)){
varFirmierung = "<Firmierung>";
}
if("".equals(varStrasze)){
varFirmierung = "<Straße-Nr>";
}
if("".equals(varOrtPlz)){
varOrtPlz = "<PLZ-Ort>";
}
if("".equals(varTel)){
varTel = "<Telefon>";
}
if("".equals(varFax)){
varFax = "<Fax>";
}
if("".equals(varEmailPx)){
varEmailPx = "<Email-Persönlich>";
}
if("".equals(varEmailSx)){
varEmailSx = "<Email-Filiale>";
}
if("".equals(varEmailKx)){
varEmailKx = "<Email-Kern>";
}
Person person = new Person(varVorname, varNachname, varFunktion);
Standort standort = new Standort(varFirmierung, varStrasze, varOrtPlz);
varEmailKx = "e-kern.de";
Kontakt kontakt = new Kontakt(varTel, varFax, varEmailPx, varEmailSx, varEmailKx);
jTextAreaAusgabe.setText("Mit freundlichen Grüßen\n\n" +
person.toPerson() + "\n\n" +
standort.toStandort() + "\n\n" +
kontakt.toKontakt());
}
private void jTextFieldFremdsprachenActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void jComboBoxFilialeActionPerformed(java.awt.event.ActionEvent evt) {
String ComboBoxFiliale = "" + jComboBoxFiliale.getSelectedItem(); //holt sich die Werte als String
//comboverzweigung(); //sollte eigentlich ausgelagert werden
switch(ComboBoxFiliale){
.... -> hier hab ich was rausgelöscht
varTelStartInt = "";
varTelEndDefault = "";
varFaxStart = "";
varFaxEndDefault = "";
break;
}
}
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
String TextAreaAusgabe = ""; //Testfeld leeren am Anfang
String homeDirectory = new JFileChooser().getFileSystemView().getHomeDirectory().toString(); //Pfadd für den Desktop
varVorname = jTextFieldVorname.getText();
varNachname = jTextFieldNachname.getText();
varFunktion = jTextFieldFunktion.getText();
varFunktionHtml = Html(varFunktion);
//Bereich
//wenn die Namensfelder frei gelassen werden passiert nichts
if("".equals(varVorname) || "".equals(varNachname) || "".equals(varFunktion) ||
"".equals(jComboBoxBereich.getSelectedItem()) || "Bereich".equals(jComboBoxBereich.getSelectedItem()) ||
"".equals(jComboBoxFiliale.getSelectedItem()) || "Filiale".equals(jComboBoxFiliale.getSelectedItem())){ //müsste noch erweitert werden mit all den anderen Feldern.
TextAreaAusgabe += "Fehler: Bitte alle notwendigen Felder ausfüllen.\n";
jPanel2.setBackground(Color.RED);
if("".equals(varVorname)){
jTextFieldVorname.setBorder(BorderFactory.createLineBorder(Color.RED));
}
if("".equals(varNachname)){
jTextFieldNachname.setBorder(BorderFactory.createLineBorder(Color.RED));
}
if("".equals(varFunktion)){
jTextFieldFunktion.setBorder(BorderFactory.createLineBorder(Color.RED));
}
if("".equals(jComboBoxBereich.getSelectedItem()) || "Bereich".equals(jComboBoxBereich.getSelectedItem())){
//jComboBoxBereich.setBorder(BorderFactory.createLineBorder(Color.RED));
jComboBoxBereich.setBackground(Color.RED);
}
if("".equals(jComboBoxFiliale.getSelectedItem()) || "Filiale".equals(jComboBoxFiliale.getSelectedItem())){
//jComboBoxFiliale.setBorder(BorderFactory.createLineBorder(Color.RED));
jComboBoxFiliale.setBackground(Color.RED);
}
}else{
//setzt Panel auf Grün, Farbe könnte man noch schöner machen
jPanel2.setBackground(Color.GREEN);
varTelEndIndiv = jTextFieldTel.getText();
varFaxEndIndiv = jTextFieldFax.getText();
//prüfe wie Nummern zusammengesetzt werden (ob individuelle Nr. oder nicht)
if("".equals(jTextFieldTel.getText()) || !jTextFieldTel.isEnabled()){ //Telefon bei keiner Eingabe
//varTel = varTelStartGer + varTelEndDefault;
varTel = varTelStartGer.concat(varTelEndDefault);
varTelInt = varTelStartInt + varTelEndDefault;
}else if(!"".equals(jTextFieldTel.getText()) || jTextFieldTel.isEnabled()){ //Telefon bei Eingabe
//varTel = varTelStartGer + varTelEndIndiv;
varTel = varTelStartGer.concat(varTelEndIndiv);
varTelInt = varTelStartInt + varTelEndIndiv;
}
if("".equals(jTextFieldFax.getText()) || !jTextFieldFax.isEnabled()){ //Fax bei keiner Engabe
varFax = varFaxStart + varFaxEndDefault;
//varFax = varFaxStart.concat(varFaxEndDefault);
}else if(!"".equals(jTextFieldFax.getText()) || jTextFieldFax.isEnabled()){ //Fax bei Eingabe
varFax = varFaxStart + varFaxEndIndiv;
//varFax = varFaxStart.concat(varFaxEndIndiv);
}
//Sprachkombination
varMuttersprache = jTextFieldMuttersprache.getText();
varFremdsprache = jTextFieldFremdsprachen.getText();
if("".equals(jTextFieldMuttersprache.getText()) || "".equals(jTextFieldFremdsprachen.getText())){
varSprachkombi = "";
}else if(!"".equals(jTextFieldMuttersprache.getText()) || !"".equals(jTextFieldFremdsprachen.getText())){
varSprachkombi = " (" + varFremdsprache + " → " + varMuttersprache + ")";
}
//Combobox mit Bereichsauswahl -> html
if(jComboBoxBereich.getSelectedItem() == "AG"){
HtmlAG html = new HtmlAG(Html(varVorname), Html(varNachname), Html(varFunktion), Html(varStrasze), Html(varOrtPlz), varTel, varTelInt, varFax, varOrt, varSprachkombi);
htmlFinal = html.toHtmlAG(); //String Ausgabe
}else if (jComboBoxBereich.getSelectedItem() == "Training"){
HtmlTR html = new HtmlTR(varVorname, varNachname, varFunktion, varStraszeHtml, varOrtPlzHtml, varTel, varTelInt, varFax, varOrt);
htmlFinal = html.toHtmlTR(); //String Ausgabe
}else if(jComboBoxBereich.getSelectedItem() == "CEF"){
HtmlCEF html = new HtmlCEF(varVorname, varNachname, varFunktion, varStraszeHtml, varOrtPlzHtml, varTel, varTelInt, varFax, varOrt);
htmlFinal = html.toHtmlCEF(); //funktioniert noch nicht, gibt im Moment nur ein "" zurück
}
//Combobox mit Bereichsauswahl -> txt
if(jComboBoxBereich.getSelectedItem() == "AG"){
TxtAG txt = new TxtAG(varVorname, varNachname, varFunktion, varStrasze, varOrtPlz, varTel, varFax, varOrt);
txtFinal = txt.toTxtAG();
}else if (jComboBoxBereich.getSelectedItem() == "Training"){
TxtTR txt = new TxtTR(varVorname, varNachname, varFunktion, varStrasze, varOrtPlz, varTel, varFax, varOrt);
txtFinal = txt.toTxtTR();
}else if(jComboBoxBereich.getSelectedItem() == "CEF"){
}
String pathname = homeDirectory + "\\" + varVorname + " " + varNachname;
File folder = new File(pathname);
try{
if(folder.exists()){
TextAreaAusgabe += "Fehler: Die Ordnerstruktur wurde bereits erstellt.\n";
}else{
folder.mkdir();
TextAreaAusgabe += "Die Ordnerstruktur wurde erfolgreich erstellt.\n";
}
}catch(Exception e){
e.printStackTrace();
}
File Fbat = new File(homeDirectory + "\\" + varVorname + " " + varNachname + "\\" + "Signatur.bat");
//Inhalt der .bat Datei - ist ziemlich kurz, deswegen nicht ausgelagert
String bat = "@echo off\nmd %APPDATA%\\Microsoft\\Signatures 1>nul 2>nul\necho.\necho.\n"
+ "echo -------------------------------------------------------------------\n"
+ "echo --Verzeichnis \"Signatures\" wurde erstellt oder existiert bereits!--\n"
+ "echo -------------------------------------------------------------------\n"
+ "echo.\necho.\npause\ncopy *.htm %APPDATA%\\Microsoft\\Signatures /Y 1>nul 2>nul\n"
+ "copy *.txt %APPDATA%\\Microsoft\\Signatures /Y 1>nul 2>nul\necho.\necho.\n"
+ "echo ---------------------------------\necho ----------- Fertig! -------------\n"
+ "echo ---------------------------------\necho --Die Signaturen wurden kopiert--\n"
+ "echo ---------------------------------\necho.\necho.\npause\nexit";
//Bat bat = new Bat(); //wollte eigentlich den bat String auslager, hat aber irgendwie nicht so richtig funktioniert
try {
BufferedWriter bw = new BufferedWriter(new FileWriter(Fbat));
bw.write(bat);
bw.close();
TextAreaAusgabe += "- bat Datei wurde erfolgreich erstellt.\n";
} catch(IOException e){
TextAreaAusgabe += "Es gabe einen Fehler, die bat Datei konnte nicht erstellt werden\n";
}
//nur als Test gedacht, braucht noch ne Verzweiung etc.
//String a = "test", b = "test", c = "test", d = "test", e = "test", f = "test", g = "test", h = "test", i = "test";
//hier wird die html Datei erstellt
//HtmlAG html = new HtmlAG(a, b, c, d, e, f, g, h, i);
File Fhtml = new File(homeDirectory + "\\" + varVorname + " " + varNachname + "\\" + varVorname + " " + varNachname + ".html");
try {
BufferedWriter bw = new BufferedWriter(new FileWriter(Fhtml));
bw.write(htmlFinal);
bw.close();
TextAreaAusgabe += "- html Datei wurde erfolgreich erstellt.\n";
} catch(IOException ee){
TextAreaAusgabe += "Es gab einen Fehler, die html Datei konnte nicht erstellt werden.\n";
}
//hier wird die txt Datei erstellt
File Ftxt = new File(homeDirectory + "\\" + varVorname + " " + varNachname + "\\" + varVorname + " " + varNachname + ".txt");
try {
BufferedWriter bw = new BufferedWriter(new FileWriter(Ftxt));
bw.write(txtFinal);
bw.close();
TextAreaAusgabe += "- txt Datei wurde erfolgreich erstellt.\n";
} catch(IOException eee){
TextAreaAusgabe += "Es gab einen Fehler, die txt Datei konnte nicht erstellt werden.\n";
}
TextAreaAusgabe += "Die Dateien befinden sich auf dem Desktop.";
}
jTextAreaAusgabe.setText(TextAreaAusgabe); //muss am Ende stehen, damit Ausgame zusammensetzt
}
private void jToggleButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String PraktM = "Praktikant", PraktW = "Praktikantin";
String text = jTextFieldFunktion.getText();
if(text.equals(PraktM) || text.equals(PraktW)) {
jToggleButton1.setSelected(true);
jTextFieldMuttersprache.setEnabled(true);
jTextFieldFremdsprachen.setEnabled(true);
jTextAreaAusgabe.setText("");
}
else{
jToggleButton1.setSelected(false);
jTextFieldMuttersprache.setEnabled(false);
jTextFieldFremdsprachen.setEnabled(false);
jTextFieldMuttersprache.setText(""); //leert das Feld nach disable
jTextFieldFremdsprachen.setText(""); //leert das Feld n ach disable
//JOptionPane.showMessageDialog(null, "Sprachkombination nur bei Praktikant/in\nBitte versuchene Sie es erneut", "Funktion stimmt nicht überein", JOptionPane.ERROR_MESSAGE);
jTextAreaAusgabe.setText("Bitte die korrekte Funktion benutzen:\nVersuche: 'Praktikant' oder 'Praktikantin'");
}
}
private void jTextFieldVornameActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
//jTextFieldVorname.addKeyListener(keyListener);
jTextFieldVorname.getDocument().addDocumentListener(documentListener);
//jTextFieldVorname.getDocument().addDocumentListener(new documentListener());
//jTextFieldVorname.keyTyped();
}
private void jComboBoxBereichActionPerformed(java.awt.event.ActionEvent evt) {
/*ComboBoxBereich = "" + jComboBoxTitel.getSelectedItem();
if("Bereich".equals(ComboBoxBereich)){
ComboBoxBereich = "";
}*/
}
private void jCheckBox1ActionPerformed(java.awt.event.ActionEvent evt) {
if(jCheckBox1.isSelected()){
jTextFieldTel.setEnabled(true);
}else{
jTextFieldTel.setEnabled(false);
jTextFieldTel.setText(""); //leert das Feld, nach disable -> wichtif für die if-Verzweigungen
}
}
private void jCheckBox2ActionPerformed(java.awt.event.ActionEvent evt) {
if(jCheckBox2.isSelected()){
jTextFieldFax.setEnabled(true);
}else{
jTextFieldFax.setEnabled(false);
jTextFieldFax.setText(""); //leert das Feld, nach disable -> wichtif für die if-Verzweigungen
}
}
private void jTextFieldFunktionActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void jComboBoxTitelActionPerformed(java.awt.event.ActionEvent evt) {
String ComboBoxTitel = "" + jComboBoxTitel.getSelectedItem();
String titelHinten = "", titelVorn = "";
switch(ComboBoxTitel){
case "B.A.":
titelHinten = ", B.A.";
break;
case "M.A.":
titelHinten = ", M.A.";
break;
case "B.Sc.":
titelHinten = ", B.Sc.";
break;
case "M.Sc.":
titelHinten = ", M.Sc";
break;
case "Mag.":
titelVorn = "Mag. ";
break;
case "Dipl.":
titelVorn = "Dipl. ";
break;
case "Dipl. (FH)":
titelVorn = "Dipl. (FH) ";
break;
case "Dr.":
titelVorn = "Dr. ";
break;
default:
titelHinten = "";
titelVorn = "";
break;
}
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
//LineBorder border = (LineBorder) borderDefault.getBorder();
/*Border border = (Border) borderDefault.getBorder();
jTextFieldVorname.setBorder(border);*/
jTextFieldVorname.setBorder(new JTextField().getBorder());
jTextFieldNachname.setBorder(new JTextField().getBorder());
jTextFieldFunktion.setBorder(new JTextField().getBorder());
jComboBoxBereich.setBackground(new JComboBox().getBackground());
jComboBoxFiliale.setBackground(new JComboBox().getBackground());
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(GUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(GUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(GUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(GUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new GUI().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JCheckBox jCheckBox1;
private javax.swing.JCheckBox jCheckBox2;
private javax.swing.JComboBox<String> jComboBoxBereich;
private javax.swing.JComboBox<String> jComboBoxFiliale;
private javax.swing.JComboBox<String> jComboBoxTitel;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabelFunktion;
private javax.swing.JLabel jLabelNachname;
private javax.swing.JLabel jLabelVorname;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JPanel jPanel4;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextArea jTextAreaAusgabe;
private javax.swing.JTextField jTextFieldFax;
private javax.swing.JTextField jTextFieldFremdsprachen;
private javax.swing.JTextField jTextFieldFunktion;
private javax.swing.JTextField jTextFieldMuttersprache;
private javax.swing.JTextField jTextFieldNachname;
private javax.swing.JTextField jTextFieldTel;
private javax.swing.JTextField jTextFieldVorname;
private javax.swing.JToggleButton jToggleButton1;
// End of variables declaration
}