JPanel nie wyświetla się.

0

Piszę sobie hobbistycznie małą gierkę. Może ktoś kojarzy planszówkę SuperFarmer :) To na razie dopiero szkielet szkieletu programu ale już mam problem.
Wszystko wygląda ok, podzieliłem główne okno na panele dla każdego przeciwnika i zrobiłem osobną klasę. Niestety panele nie wyświetlają się.
Jaka jest tego przyczyna?

Klasa panelu

package game;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;

import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class OpponentPanel extends JPanel {
    private String name;

    private JLabel lTitle;

    public OpponentPanel(String name) {
        super();
        setPreferredSize(new Dimension(400, 300));
        setLayout(null);
        this.name = name;

        lTitle = new JLabel(name);
        lTitle.setBounds(10, 10, 200, 50);
        lTitle.setFont(new Font(null, Font.BOLD, 18));
        add(lTitle);

        this.setBorder(BorderFactory.createLineBorder(Color.BLACK));

    }
}

Klasa okna

package game;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;

import javax.swing.JFrame;

public class FarmerClientFrame extends JFrame {
    private Game game;

    public FarmerClientFrame(Game game) {
        this.game = game;

        setSize(1200, 900);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setTitle("SuperFarmer  v." + game.getVersion());
        setLocationRelativeTo(null);
        setResizable(false);

        GridBagLayout gbl = new GridBagLayout();
        setLayout(gbl);

        MyPanel panel0 = new MyPanel();
        GridBagConstraints GBCpanel0 = new GridBagConstraints();
        GBCpanel0.weightx = 1200;
        GBCpanel0.weighty = 300;
        GBCpanel0.gridx = 0;
        GBCpanel0.gridy = 2;
        GBCpanel0.gridwidth = 3;
        GBCpanel0.gridheight = 1;
        add(panel0, GBCpanel0);

        OpponentPanel panel1 = new OpponentPanel("Opponent1");
        GridBagConstraints GBCpanel1 = new GridBagConstraints();
        GBCpanel1.weightx = 400;
        GBCpanel1.weighty = 300;
        GBCpanel1.gridx = 1;
        GBCpanel1.gridy = 0;
        GBCpanel1.gridwidth = 1;
        GBCpanel1.gridheight = 1;
        add(panel1, GBCpanel1);

        OpponentPanel panel2 = new OpponentPanel("Opponent2");
        GridBagConstraints GBCpanel2 = new GridBagConstraints();
        GBCpanel2.weightx = 400;
        GBCpanel2.weighty = 300;
        GBCpanel2.gridx = 0;
        GBCpanel2.gridy = 0;
        GBCpanel2.gridwidth = 1;
        GBCpanel2.gridheight = 1;
        add(panel2, GBCpanel2);

        OpponentPanel panel3 = new OpponentPanel("Opponent3");
        GridBagConstraints GBCpanel3 = new GridBagConstraints();
        GBCpanel3.weightx = 400;
        GBCpanel3.weighty = 300;
        GBCpanel3.gridx = 2;
        GBCpanel3.gridy = 0;
        GBCpanel3.gridwidth = 1;
        GBCpanel3.gridheight = 1;
        add(panel3, GBCpanel3);

        OpponentPanel panel4 = new OpponentPanel("Opponent4");
        GridBagConstraints GBCpanel4 = new GridBagConstraints();
        GBCpanel4.weightx = 400;
        GBCpanel4.weighty = 300;
        GBCpanel4.gridx = 0;
        GBCpanel4.gridy = 1;
        GBCpanel4.gridwidth = 1;
        GBCpanel4.gridheight = 1;
        add(panel4, GBCpanel4);

        OpponentPanel panel5 = new OpponentPanel("Opponent5");
        GridBagConstraints GBCpanel5 = new GridBagConstraints();
        GBCpanel5.weightx = 400;
        GBCpanel5.weighty = 300;
        GBCpanel5.gridx = 2;
        GBCpanel5.gridy = 1;
        GBCpanel5.gridwidth = 1;
        GBCpanel5.gridheight = 1;
        add(panel5, GBCpanel5);

    }

}
0

dodałem setVisible() do panelu i dalej nic. Widoczność okna była już ustawiona w innej klasie w której jest tworzone okno.

1 użytkowników online, w tym zalogowanych: 0, gości: 1, botów: 0