JToolBar toolBar = new JToolBar("工具栏");
toolBar.setFloatable(false);
// toolBar.setBackground(java.awt.Color.GREEN);
final ButtonGroup buttonGroup = new ButtonGroup();
JToggleButton homeBtn = new JToggleButton(IconUtils.createImageIcon(ICON_CLASS_PATH + "home.png"));
JToggleButton generatorBtn = new JToggleButton(IconUtils.createImageIcon(ICON_CLASS_PATH + "jarbundler.png"));
JToggleButton designerBtn = new JToggleButton(IconUtils.createImageIcon(ICON_CLASS_PATH + "design.png"));
JToggleButton templateBtn = new JToggleButton(IconUtils.createImageIcon(ICON_CLASS_PATH + "template.png"));
JToggleButton viewBtn = new JToggleButton(IconUtils.createImageIcon(ICON_CLASS_PATH + "Cube.png"));
this.logoLabel = new JLabel(IconUtils.createImageIcon(IMAGE_CLASS_PATH + "xgenerator.png"));
this.logoLabel.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
buttonGroup.clearSelection();
logoLabel.requestFocusInWindow();
}
});
homeBtn.setText("首页");
homeBtn.setToolTipText("首页");
homeBtn.setHorizontalTextPosition(JButton.CENTER);
homeBtn.setHorizontalAlignment(JButton.CENTER);
homeBtn.setVerticalTextPosition(JButton.BOTTOM);
generatorBtn.setText("代码生成器");
generatorBtn.setToolTipText("元数据代码生成器");
generatorBtn.setHorizontalTextPosition(JButton.CENTER);
generatorBtn.setHorizontalAlignment(JButton.CENTER);
generatorBtn.setVerticalTextPosition(JButton.BOTTOM);
generatorBtn.setVerticalTextPosition(JButton.BOTTOM);
generatorBtn.setActionCommand(MenuAdapter.METADATA_GENERATOR_COMMAND);
generatorBtn.addActionListener(this.menuAction);
designerBtn.setText("查询设计器");
designerBtn.setToolTipText("查询设计器");
designerBtn.setHorizontalTextPosition(JButton.CENTER);
designerBtn.setHorizontalAlignment(JButton.CENTER);
designerBtn.setVerticalTextPosition(JButton.BOTTOM);
templateBtn.setText("模板管理");
templateBtn.setToolTipText("模板管理");
templateBtn.setHorizontalTextPosition(JButton.CENTER);
templateBtn.setHorizontalAlignment(JButton.CENTER);
templateBtn.setVerticalTextPosition(JButton.BOTTOM);
viewBtn.setText("布局排版");
viewBtn.setToolTipText("界面布局排版");
viewBtn.setHorizontalTextPosition(JButton.CENTER);
viewBtn.setHorizontalAlignment(JButton.CENTER);
viewBtn.setVerticalTextPosition(JButton.BOTTOM);
buttonGroup.add(homeBtn);
buttonGroup.add(generatorBtn);
buttonGroup.add(designerBtn);
buttonGroup.add(templateBtn);