Skip to content
Advertisement

I have a problem whith adding a Container in a JFrame

I am a student in informatics and beginning in Java, I want to create a project which will allow me to make a calculator.

I am encountering a problem which is the following: I want to add Container in my JFrame with add(contenu), but it gives me the following warning :

JavaScript

I don’t understand why this problem appears.

Here are the class codes of my project:

class Main :

JavaScript

class Fenetre :

JavaScript

Have you any idea about why this problem appears?

Advertisement

Answer

As one of the comments already mentions you are trying to add the JFrame’s content pane to itself.

The following will work:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement