JButton cancel = new JButton("Abbrechen");
final JTextField fieldWord = new JTextField();
final JTextField fieldTransWord = new JTextField();
JButton transWord = new JButton("Übersetzung",new ImageIcon("icons/asterisk_orange.png"));
JLabel timeLab = new JLabel("Datum");
final JDateChooser timestamp = new JDateChooser();
transWord.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent ae) {
String translation = (String)JOptionPane.showInputDialog(null, "Bitte wählen Sie die Zielsprache aus:", "Zielsprache",
JOptionPane.QUESTION_MESSAGE, null, new Object[] { "de",
"en", "fr", "es", "it" }, "fr");
if(translation != null){
fieldTransWord.setText(ba.getTranslation(fieldWord.getText(), "", translation));
}
}
});
// Daten fuellen
final String[] data = (!edit?new String[0]:ba.getVokabel(id));
if(edit){
// Daten holen
fieldWord.setText(data[2]);
fieldTransWord.setText(data[3]);
timestamp.setDate(new Date(Long.parseLong(data[1])*1000));
cate.setSelectedItem(data[5]);
}
final JDialog newVokWin;
Container vokCon;
newVokWin = new JDialog();
newVokWin.setModalityType(JDialog.ModalityType.APPLICATION_MODAL);
vokCon = newVokWin.getContentPane();
vokCon.setLayout(new GridLayout(/*3*/ 0, 2, 6, 3));
newVokWin.setTitle("Neue Vokabel eintragen");
newVokWin.setSize(600,300);
newVokWin.setLocation(300,300);
// Tasten
cancel.setMnemonic('A');
save.setMnemonic('S');
// here we add the controls to the container.
vokCon.add(labCate, "labCate");
vokCon.add(cate, "cate");
vokCon.add(word, "word");
vokCon.add(fieldWord, "fieldWord");
vokCon.add(transWord, "transWord");
vokCon.add(fieldTransWord, "fieldTransWord");
vokCon.add(timeLab, "timeLab");
vokCon.add(timestamp, "timestamp");
vokCon.add(save, "save");
vokCon.add(cancel, "cancel");
// Aktionen
cancel.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent evt){
newVokWin.dispose();
}
});
save.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent evt){
if(ba.checkInput(fieldWord.getText(),fieldTransWord.getText())){
if(!edit){
ba.saveInput(""+cate.getSelectedItem(),fieldWord.getText(),fieldTransWord.getText(),timestamp.getDate());
}else{
ba.saveInput(""+cate.getSelectedItem(),fieldWord.getText(),fieldTransWord.getText(),timestamp.getDate(), data[0], true);
}
newVokWin.dispose();
if(category){
showVokabeln(categoryName, true);
}else{