adding JLabels and JTextFields to a specific JtabbedPane [resolved]
hi,
well i am have spent to long pulling my hair out over this one, so i thought i would ask someone who might know. I have four tabs on one main JTabbedpane, and what i want to do is add JButtons and Jlabels to specific Jtabs, everytime i do it seems to put the object in another tab and when i sort of managed to add a JLabel to a tab it overwrote all of the settings, here is the code that i have so far
Code:
//this needs to be protected so that the JTabbedPanel thing works, otherwise i get silly errors
protected Component makeTextPanel (String text)
{
JPanel panel = new JPanel (false);
JLabel filler = new JLabel (text);
filler.setHorizontalAlignment (JLabel.CENTER);
panel.setLayout (new GridLayout (1,1));
panel.add (filler);
return panel;
}
public PennysPapers()
{
super("Pennys Papers");
this.setBounds(200,200,600,400); // x, y offset, width, height
this.getContentPane().setBackground(Color.yellow);
WindowHandler w = new WindowHandler();
this.addWindowListener(w);
getContentPane().setLayout (new BorderLayout ());
JPanel mainPanel = new JPanel (new BorderLayout());
JTabbedPane tabPane = new JTabbedPane();
ImageIcon Icon = new ImageIcon("welcome.jpg");
//adding the first tab to the thingy
Component panel1 = makeTextPanel("OMEGA");
JPanel tabPanel1 = new JPanel(new BorderLayout());
tabPane.addTab("Welcome", null, panel1, "Welcome to Pennys Papers");
tabPane.setToolTipText("Welcome to Pennys Papers");
tabPane.add(new JLabel(Icon),"Welcome");
tabPane.setSelectedIndex(0);
tabPane.add(new JButton("I AM WEASEL"));
//adding the second panel
Component panel2 = makeTextPanel("Publications");
tabPane.addTab("Publications", null, panel2, "Add and remove publications");
//adding the third panel
Component panel3 = makeTextPanel("Customers");
tabPane.addTab("Customers", null, panel3, "Add and remove customers");
//addinf the fourth panel
Component panel4 = makeTextPanel("Rounds");
tabPane.addTab("Rounds", null, panel4, "Organise paper rounds");
tabPanel1.add(panel1, BorderLayout.CENTER);
mainPanel.add(tabPanel1, BorderLayout.CENTER);
mainPanel.add(tabPane, BorderLayout.CENTER);
getContentPane().add(mainPanel);
//this.pack(); OMG !!! Resistance is Futile :p
}
thanks for any help with this
:)