I've created a new JFrame, set the layout to "BorderLayout" and placed a JTabbedPane in the middle (center) of the contentPane.
Then I've added a new tab (JPanel) to the JTabbedPane. Next I've set a label to the new created tab. (see attached print screen)
When I run the generated main-class so I don't see the tab!
In the generated source code, the method to add the JPanel will never be called! (see source code snip below)
Do you know this bug?
Is there a simple solution to resolve this problem?
Greets, Mike
- Code: Select all
public class TabbedPaneTest extends JFrame
{
private JLabel label;
private JPanel panel;
private JTabbedPane tabbedPane;
public static void main(String args[])
{
TabbedPaneTest frame = new TabbedPaneTest();
frame.setBounds(100, 100, 500, 375);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
public TabbedPaneTest()
{
super();
getContentPane().setLayout(new BorderLayout());
getContentPane().add(getTabbedPane(), BorderLayout.CENTER);
//
}
protected JTabbedPane getTabbedPane()
{
if (tabbedPane == null) {
tabbedPane = new JTabbedPane();
}
return tabbedPane;
}
protected JPanel getPanel() // --> Will be never done! <-- \\
{
if (panel == null) {
panel = new JPanel();
getTabbedPane().addTab("New tab", null, panel, null);
panel.add(getLabel());
}
return panel;
}
protected JLabel getLabel()
{
if (label == null) {
label = new JLabel();
label.setText("New JLabel");
}
return label;
}
}