`
majm
  • 浏览: 34599 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

JToolBar

 
阅读更多
public class JToolBarTest extends JFrame{

private JToolBar toolBar;
private JButton button1,button2;
private JLabel label1,label2;
private JPanel panle;

public JToolBarTest(){
  toolBar = new JToolBar("工具箱");
  button1 = new JButton("button1");
  button2 = new JButton("button2");
 
  panle= new JPanel();
  label1 =  new JLabel("label1: ");
  label2 =  new JLabel("label2: ");
  toolBar.setFloatable(true);
 
  toolBar.add(button1);
  toolBar.add(button2);
  toolBar.addSeparator();
  panle.add(label1,BorderLayout.EAST);
//   toolBar.addSeparator();
  panle.add(label2,BorderLayout.EAST);
 
  toolBar.add(panle,BorderLayout.EAST);
  getContentPane().add(toolBar,BorderLayout.NORTH);
 
  setSize(200,300);
  setVisible(true);
}
public static void main(String[] args) {
  JToolBarTest application = new JToolBarTest();
  application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics