Link to home
Start Free TrialLog in
Avatar of asukai
asukai

asked on

Layout Problem

Please follow the link below. I got a layout problem. Thanx
http://www.penne.jp/layoutprob.htm
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Try

toolBar.setLayout(new FlowLayout());
Avatar of asukai
asukai

ASKER

It brings all the componets to the center of the toolbar.
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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,BorderLayout.NORTH);
}