Hi I am trying to move JTabbedPane down below top panel.I want it where the bottom panel begin.Thanks.
import java.awt.*;
import javax.swing.*;
public class GridBagLayoutTest
{
JPanel bottomPanel;
JPanel topPanel;
public GridBagLayoutTest()
{
JFrame frame = new JFrame("GridBag Layout Test");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLocationByPlatform(true);
JTabbedPane tabbed=new JTabbedPane();
tabbed.add(bottomPanel,"One Way");
tabbed.setBounds(12, 200, 20, 20);
//tabbed.setTabPlacement(JTabbedPane.BOTTOM);
Container container = frame.getContentPane();
container.setLayout(new GridBagLayout());
topPanel = new JPanel();
topPanel.setBackground(Color.BLUE);
topPanel.setPreferredSize(new Dimension(290,80));
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
gbc.anchor = GridBagConstraints.FIRST_LINE_START;
gbc.fill = GridBagConstraints.BOTH;
container.add(topPanel, gbc);
bottomPanel = new JPanel();
bottomPanel.setPreferredSize(new Dimension(120,270));
bottomPanel.setBackground(Color.WHITE);
bottomPanel.add(topPanel);
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 1;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
gbc.anchor = GridBagConstraints.LAST_LINE_START;
gbc.fill = GridBagConstraints.BOTH;
container.add(bottomPanel, gbc);
container.add(tabbed,new GridBagConstraints(0,0,1,1,1.0,1.0
,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 4, 5, 4), -2, -1));
frame.setSize(300, 400);
frame.setVisible(true);
}
public static void main(String... args)
{
Runnable runnable = new Runnable()
{
public void run()
{
new GridBagLayoutTest();
}
};
SwingUtilities.invokeLater(runnable);
}
}