package iban;
import java.awt.*;
import java.io.BufferedWriter;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Locale;
import javax.swing.JFrame;
import javax.swing.JFileChooser;
import javax.swing.JPanel;
import javax.swing.border.*;
import javax.swing.plaf.synth.*;
import javax.swing.LookAndFeel;
import javax.xml.parsers.*;
import javax.swing.JComponent;
import javax.swing.JTextField;
import javax.swing.JLabel;
import javax.swing.JButton;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.Box;
import javax.swing.JSeparator;
import javax.swing.JToggleButton;
import javax.swing.UIManager;
import javax.swing.WindowConstants;
import javax.swing.JCheckBox;
import java.awt.event.*;
public class SepaRechner3 extends JFrame implements WindowListener {
private JPanel contentPane;
private JTextField jTFChooseFile;
private JTextField jTFKonto;
private JTextField jTFBlz;
private JTextField jTFName;
private JTextField jTFBetrag;
private JTable jTabDaten;
public void windowClosing(WindowEvent e) {
}
public void windowClosed(WindowEvent e) {
}
public void windowOpened(WindowEvent e) {
}
public void windowIconified(WindowEvent e) {
}
public void windowDeiconified(WindowEvent e) {
}
public void windowActivated(WindowEvent e) {
}
public void windowDeactivated(WindowEvent e) {
}
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
SepaRechner3 frame = new SepaRechner3();
//frame.setUndecorated(true);
frame.setVisible(true);
frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
/*frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent evt) {
onClose();
System.exit(0);
};
});*/
String path= System.getProperty("user.dir");
File config= new File("config.txt");
//String outdatei= path+ sepaEingabe+ datum+ ".csv";
if(!config.exists()) {
try {
FileWriter writer= new FileWriter(config);
//System.out.println(System.getProperty("user.dir"));
writer.write("path "+ System.getProperty("user.dir"));
writer.close();
path= System.getProperty("user.dir");
} catch (Exception e) {
e.printStackTrace();
}
} else {
//path= "c:/Users/schach/Thomas/FChO/CDS/CDS-Finanzen/SEPA-Eingabe/";
if (getConfig("path").equals("")) {
path= System.getProperty("user.dir");
} else path= getConfig("path");
}
frame.jTFChooseFile.setText(path);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/*public void onClose() {
jCheckKeep.isSelected();
System.exit(0);
}*/
public void changeDirectory() {
JFileChooser fc= new JFileChooser();
fc.setCurrentDirectory(new File(System.getProperty("user.dir")));
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
if (fc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
jTFChooseFile.setText(fc.getSelectedFile().getPath());
}
}
static String getConfig(String prop) {
File config= new File("config.txt");
BufferedReader in;
String zeile, result= "";
try {
in= new BufferedReader(new FileReader(config));
while ((zeile= in.readLine()) != null) {
if (zeile.substring(0, prop.length()).equals(prop)) {
result= zeile.substring(prop.length()+1, zeile.length());
}
}
if (in != null) {
try {
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
/**
* Create the frame.
*/
public SepaRechner3() {
Color fcho = new Color(163,64,113);
setTitle("Sepa-Rechner v3.0");
setFont(new Font("Gill Sans MT", Font.PLAIN, 13));
setForeground(fcho);
setBounds(100, 100, 675, 500);
contentPane = new JPanel();
contentPane.setFont(new Font("Gill Sans MT", Font.PLAIN, 13));
contentPane.setBackground(Color.WHITE);
contentPane.setForeground(fcho);
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
jTFChooseFile = new JTextField();
jTFChooseFile.setFont(new Font("Gill Sans MT", Font.PLAIN, 13));
jTFChooseFile.setBorder(new LineBorder(fcho));
jTFChooseFile.setForeground(fcho);
jTFChooseFile.setBounds(10, 25, 375, 20);
contentPane.add(jTFChooseFile);
jTFChooseFile.setColumns(10);
JLabel jLChooseFile = new JLabel("Zieldatei");
jLChooseFile.setFont(new Font("Gill Sans MT", Font.PLAIN, 13));
jLChooseFile.setForeground(fcho);
jLChooseFile.setBounds(10, 10, 375, 14);
contentPane.add(jLChooseFile);
JButton btnChooseFile = new JButton("Auswählen...");
btnChooseFile.setFont(new Font("Gill Sans MT", Font.PLAIN, 13));
btnChooseFile.setBackground(fcho);
btnChooseFile.setBounds(395, 25, 110, 20);
btnChooseFile.setForeground(Color.WHITE);
btnChooseFile.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
changeDirectory();
}
});
contentPane.add(btnChooseFile);
JCheckBox jCheckKeep = new JCheckBox("Speicherort beibehalten");
jCheckKeep.setFont(new Font("Gill Sans MT", Font.PLAIN, 11));
jCheckKeep.setSelected(true);
jCheckKeep.setForeground(fcho);
jCheckKeep.setBounds(511, 25, 139, 20);
contentPane.add(jCheckKeep);
this.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent evt) {
boolean selected= jCheckKeep.isSelected();
if (selected) {
System.out.println("selected");
}
System.exit(0);
};
});
JLabel jLKonto = new JLabel("IBAN/Kontonummer");
jLKonto.setEnabled(true);
jLKonto.setFont(new Font("Gill Sans MT", Font.PLAIN, 13));
jLKonto.setForeground(fcho);
jLKonto.setBounds(10, 70, 190, 14);
contentPane.add(jLKonto);
jTFKonto = new JTextField();
jTFKonto.setFont(new Font("Gill Sans MT", Font.PLAIN, 13));
jTFKonto.setBorder(new LineBorder(fcho));
jTFKonto.setForeground(fcho);
jTFKonto.setBounds(10, 85, 190, 20);
contentPane.add(jTFKonto);
jTFKonto.setColumns(10);
JLabel jLBlz = new JLabel("BLZ");
jLBlz.setEnabled(false);
jLBlz.setFont(new Font("Gill Sans MT", Font.PLAIN, 13));
jLBlz.setForeground(fcho);
jLBlz.setBounds(210, 70, 175, 14);
contentPane.add(jLBlz);
jTFBlz = new JTextField();
jTFBlz.setEnabled(false);
jTFBlz.setBorder(new LineBorder(fcho));
jTFBlz.setFont(new Font("Gill Sans MT", Font.PLAIN, 13));
jTFBlz.setForeground(fcho);
jTFBlz.setBounds(210, 85, 175, 20);
contentPane.add(jTFBlz);
jTFBlz.setColumns(10);
JLabel jLBank = new JLabel("Bank");
jLBank.setFont(new Font("Gill Sans MT", Font.PLAIN, 13));
jLBank.setForeground(fcho);
jLBank.setBounds(10, 115, 190, 14);
contentPane.add(jLBank);
JLabel jLBic = new JLabel("BIC");
jLBic.setFont(new Font("Gill Sans MT", Font.PLAIN, 13));
jLBic.setForeground(fcho);
jLBic.setBounds(210, 115, 175, 14);
contentPane.add(jLBic);
jTFName = new JTextField();
jTFName.setFont(new Font("Gill Sans MT", Font.PLAIN, 13));
jTFName.setBorder(new LineBorder(fcho));
jTFName.setForeground(fcho);
jTFName.setBounds(10, 155, 190, 20);
contentPane.add(jTFName);
jTFName.setColumns(10);
JLabel jLName = new JLabel("Kontoinhaber");
jLName.setFont(new Font("Gill Sans MT", Font.PLAIN, 13));
jLName.setForeground(fcho);
jLName.setBounds(10, 140, 190, 14);
contentPane.add(jLName);
JLabel jLBetrag = new JLabel("\u00DCberweisungsbetrag");
jLBetrag.setFont(new Font("Gill Sans MT", Font.PLAIN, 13));
jLBetrag.setForeground(fcho);
jLBetrag.setBounds(210, 140, 175, 14);
contentPane.add(jLBetrag);
jTFBetrag = new JTextField();
jTFBetrag.setFont(new Font("Gill Sans MT", Font.PLAIN, 15));
jTFBetrag.setBorder(new LineBorder(fcho));
jTFBetrag.setForeground(fcho);
jTFBetrag.setBounds(210, 155, 175, 20);
contentPane.add(jTFBetrag);
jTFBetrag.setColumns(10);
JScrollPane scrollPane = new JScrollPane();
scrollPane.setFont(new Font("Gill Sans MT", Font.PLAIN, 13));
scrollPane.setBorder(new LineBorder(fcho));
scrollPane.setForeground(fcho);
scrollPane.setBounds(10, 304, 489, 84);
contentPane.add(scrollPane);
String[] columnNames = {"Kontoinhaber", "IBAN", "Bank", "BIC", "Betrag"};
Object[][] data = {};
jTabDaten= new JTable(data, columnNames);
jTabDaten.getTableHeader().setFont(new Font("Gill Sans MT", Font.PLAIN, 13));
jTabDaten.getTableHeader().setForeground(Color.WHITE);
jTabDaten.getTableHeader().setBackground(fcho);
jTabDaten.setFont(new Font("Gill Sans MT", Font.PLAIN, 15));
jTabDaten.setBorder(new LineBorder(fcho));
jTabDaten.setForeground(fcho);
jTabDaten.setColumnSelectionAllowed(true);
scrollPane.setViewportView(jTabDaten);
jTabDaten.setFillsViewportHeight(true);
JSeparator separator = new JSeparator();
separator.setForeground(fcho);
separator.setBounds(0, 60, 700, 2);
contentPane.add(separator);
}
}