asukai
asked on
Layout Problem
Please follow the link below. I got a layout problem. Thanx
http://www.penne.jp/layoutprob.htm
http://www.penne.jp/layoutprob.htm
ASKER
It brings all the componets to the center of the toolbar.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Other than trying FlowLayout, you might consider BorderLayout. Following is the code based on your source code on the site.
TestFrame()
{
setSize(500, 500);
JToolBar toolBar= new JToolBar();
toolBar.setLayout(new BorderLayout());
toolBar.add(new JButton("Test1"), BorderLayout.WEST);
toolBar.add(new JTextField(), BorderLayout.CENTER);
toolBar.add(new JLabel("px"), BorderLayout.EAST);
Container contentPane = getContentPane();
contentPane.add(toolBar,Bo rderLayout .NORTH);
}
TestFrame()
{
setSize(500, 500);
JToolBar toolBar= new JToolBar();
toolBar.setLayout(new BorderLayout());
toolBar.add(new JButton("Test1"), BorderLayout.WEST);
toolBar.add(new JTextField(), BorderLayout.CENTER);
toolBar.add(new JLabel("px"), BorderLayout.EAST);
Container contentPane = getContentPane();
contentPane.add(toolBar,Bo
}
toolBar.setLayout(new FlowLayout());