In my main I loop over each League
as below:
for (League l : t.getLeagues()) {
LeaguePanel leaguePanel = new LeaguePanel(l);
roundTabs.addTab(l.getName(), leaguePanel);
}
This should then create a JPanel
and add it to the tab.
public class LeaguePanel extends JPanel {
private League league;
private JComboBox roundComboBox;
LeaguePanel(League l) {
league = l;
JPanel leagePanel = new JPanel();
leagePanel.add(new JLabel("Tournament Information"));
}
However, the tab gets created but nothing appears within it
Any ideas why?
答案 0 :(得分:4)
You want to add things to your LeaguePanel
object, not to a new JPanel
:
JPanel leagePanel = new JPanel();
leagePanel.add(new JLabel("Tournament Information"));
becomes
this.add(new JLabel("Tournament Information"));
Because it's your LeaguePanel
that you add to the tabbed pane .