Hi!

I'd like to create a simple table game by Swing. I have a JFrame and a JPanel variable.
I want to add JButtons to this JPanel, but I'd like to create an own class.
I made a class that extends JButton (inheritence):

public class GameField extends JButton {...}

So I could add GameFields to the JPanel.

But I'd like to create GameFields by composition:

public class GameField{

    private JButton button;

}

But in this clase how I can add GameField to JPanel? Can I solve this problem by compisition?

I don't believe you can. You can only add Swing/AWT components to a JPanel.