Error here:
if (actionEvent.getActionCommand() == "Tarif Änderung") {
Don't use ==
to compare Strings but rather use the equals(...)
or the equalsIgnoreCase(...)
method instead. Understand that == checks if the two objects are the same which is not what you're interested in. The methods on the other hand check if the two Strings have the same characters in the same order, and that's what matters here. So instead of
if (fu == "bar") {
// do something
}
do,
if ("bar".equals(fu)) {
// do something
}
or,
if ("bar".equalsIgnoreCase(fu)) {
// do something
}
or for your program:
if ("Tarif Änderung".equals(actionEvent.getActionCommand())) {
// ....
}
Note also that
- you're calling
setVisible(true)
on components that don't need this. - You're calling
setPreferredSize(...)
on a GUI after callingpack()
which won't work. - You should avoid setting sizes and preferred sizes at all if possible but instead let components size to their natural sizes.