想用java做编辑器,想把工具栏放到左侧,几种能想到的布局都试了试,但好像都不行,不知道问题出哪儿了,求各位大哥大姐们路过教教啊~~
import java.awt.GridLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JToolBar;
/**
* http://bbs.csdn.net/topics/390333443
* @author cecil
*
*/
public class ToolBarTest extends JFrame{
public static void main(String[] args){
new ToolBarTest();
}
public ToolBarTest(){
setVisible(true);
setSize(300, 300);
JToolBar bar=new JToolBar();
bar.setLayout(new GridLayout(10,1));
for(char a:"这个应该行吧".toCharArray())
bar.add(new JButton(a+""));
add(bar,BorderLayout.WEST );
}
}
new JToolBar(JToolBar.VERTICAL)