Menu

#34 Nested JTabbedPanes can cause cpu to max out

open
nobody
None
5
2004-12-16
2004-12-16
Anonymous
No

The following example will cause the cpu to max out.
This is true for GridLayout, GridBagLayout, BoxLayout
and BorderLayout, but not FlowLayout. Also, the outer
JTabbedPane must have a tab placement of BOTTOM
and the inner JTabbedPane must have a tab placement
of TOP for the problem to occur. I'm using liquid 0.2.9-
alpha5.

Cheers, peter.williams@paremus.com

BTW, the liquid l'n'f looks excellent - great job!

import java.awt.GridLayout;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.WindowConstants;

public class TestTabbedPanes
{

public TestTabbedPanes()
{
JFrame frame = new JFrame();
frame.setSize(900, 700);
frame.setDefaultCloseOperation
(WindowConstants.EXIT_ON_CLOSE);

JTabbedPane tabbedPane1 = new JTabbedPane();
JTabbedPane tabbedPane2 = new JTabbedPane();
JPanel panel = new JPanel();

panel.setLayout(new GridLayout(1, 1));
panel.add(tabbedPane2);

frame.getContentPane().add(tabbedPane1);

tabbedPane1.setTabPlacement
(JTabbedPane.BOTTOM);
tabbedPane2.setTabPlacement(JTabbedPane.TOP);
tabbedPane1.addTab("nested tab", panel);

frame.setVisible(true);
}

public static void main(String[] args)
{
new TestTabbedPanes();
}
}

Discussion


Log in to post a comment.

MongoDB Logo MongoDB