0

I am trying to add multiple panels to a JFrame. I have set a content pane and added both panels to this pain yet only 1 is out putted.

    GraphicsPanel gp = new GraphicsPanel();
    JPanel main = new JPanel();
    TextPanel tp = new TextPanel();
    tp.setVisible(true);
    gp.setVisible(true);
    main.setLayout(new GridLayout(0, 2));
    main.add(tp);
    main.add(gp);


    MenuDriver me = new MenuDriver();
    me.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    me.setVisible(true);
    me.setContentPane(main);
  • 2
    Your question translated is: "I don't yet understand how to use the Swing layout managers", and the solution is to study them. Please check the [layout manager tutorial](https://docs.oracle.com/javase/tutorial/uiswing/layout/index.html). – Hovercraft Full Of Eels Jan 04 '17 at 14:44
  • All components should be added to the frame BEFORE the frame is made visible. If that doesn't help then post a proper [mcve] that demonstrates your problem. And since we don't have access to your custom panels, first test your code using two JLabels. Once you are able to make the two labels show, then the logic will be the same for two panels. – camickr Jan 04 '17 at 15:27

0 Answers0