SuperX-Kernmodul
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

68 lines
2.3 KiB

package de.memtext.widgets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Date;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import de.memtext.util.DateUtils;
/**
* Ein StandLabel Panel, das auch Standänderungen übernehmen kann.
* Es muss performStandChange implementiert werden
*/
public abstract class StandBox extends VerticalBox {
protected JLabel lblStand = new JLabel();
protected JButton btnStand;
private boolean isStandChanged;
protected StandBox() {
this.addWithCenterAlignment(lblStand);
btnStand = new JButton("Stand ändern");
btnStand.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
String neuerStand = JOptionPane.showInputDialog(lblStand,
"Neues Datum eingeben:", "Stand ändern",
JOptionPane.QUESTION_MESSAGE);
if (neuerStand == null)
return;
if (!DateUtils.isValidDateStrict(neuerStand)) {
WarningMessage.show(lblStand, neuerStand
+ " ist kein gültiges Datum\nBitte im Format tt.mm.jjjj eingeben", "Standänderung");
} else
try {
performStandChange(neuerStand);
lblStand.setText(neuerStand);
} catch (Exception e) {
WarningMessage.show(lblStand,
"Standänderung fehlgeschlagen.\n"
+ e.toString(), "Standänderung");
}
}
});
this.addWithCenterAlignment(btnStand);
}
public void setStandLblText(Date stand) {
lblStand.setText("Stand: "+DateUtils.format(stand));
}
protected abstract void performStandChange(String neuerStand)
throws Exception;
public boolean isStandChanged() {
return isStandChanged;
}
public void setStandChanged(boolean isStandChanged) {
this.isStandChanged = isStandChanged;
}
}
//Created on 31.05.2005 at 18:29:44