All you're doing is setting a non-displayed property of your new class and leaving the name state of the original parent class unchanged. Solution: use the super's constructor to help you out:
public FightButton(String name) {
super(name);
}
In fact there really is no need for your FlightButton to have a name field since all that does is shadow the JButton's name field. In fact if this is all you add to FlightButton, I would get rid of this class and simply use JButton objects. Myself, that is what I usually do -- use plain vanilla JButtons, but use custom AbstractActions, and I feel that is likely where your energies should go.
Edit
You state in comment:
thank you i did now know that you have to use the super constructor to do that.
You don't have to, as you could also use setter methods and the like, but if you want your constructor to behave like a JButton's similar constructor, best to use the parent's constructor.
Edit 2
For example:
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import javax.swing.*;
public class FightPanel extends JPanel {
public static final int FP_WIDTH = 600;
public static final int FP_HEIGHT = 600;
public FightPanel() {
setLayout(new BorderLayout());
JButton test = new JButton(new FightAction("Test", KeyEvent.VK_T));
add(test);
}
@Override
public Dimension getPreferredSize() {
return new Dimension(FP_WIDTH, FP_HEIGHT);
}
private static void createAndShowGui() {
FightPanel mainPanel = new FightPanel();
JFrame frame = new JFrame("FightPanel");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(mainPanel);
frame.pack();
frame.setLocationByPlatform(true);
frame.setVisible(true);
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGui();
}
});
}
}
class FightAction extends AbstractAction {
public FightAction(String name, int mnemonic) {
super(name);
putValue(MNEMONIC_KEY, mnemonic);
}
@Override
public void actionPerformed(ActionEvent e) {
System.out.println(e.getActionCommand() + " pressed!");
}
}