Lorsque j'ajoute plus d'un composant sur le JFrame, seul le composant qui a été ajouté en dernier est affiché, les autres ne sont pas affichés, quel est le problème avec leur visibilité?Comment définir plusieurs composants visibles sur un JFrame?
import java.awt.GraphicsEnvironment;
import java.awt.Point;
import java.awt.*;
import javax.swing.JFrame;
import javax.swing.JButton;
import javax.swing.JLabel;
public class CenteringaWindow {
public static void main(String[] args) {
JFrame aWindow = new JFrame("This is the Window Title");
Point center = GraphicsEnvironment.getLocalGraphicsEnvironment().getCenterPoint();
int windowWidth = 400;
int windowHeight = 150;
JButton item1=new JButton("hiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii");
JButton item2=new JButton("how are you ?");
aWindow.add(item1);
aWindow.add(item2);
JLabel label1=new JLabel("Label 1");
aWindow.add(label1);
JLabel label2=new JLabel("Label 2");
aWindow.add(label2);
//center align the JFrame
aWindow.setLocationRelativeTo(null);
aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
aWindow.setVisible(true); // Display the window
}}