packagecom.szss.mainFrame;import staticjavax.swing.BorderFactory.createTitledBorder;importjava.awt.Color;importjava.awt.EventQueue;importjava.awt.Font;importjavax.swing.JFrame;importjavax.swing.JPanel;importjavax.swing.SwingConstants;importjavax.swing.SwingUtilities;importjavax.swing.UIManager;importjavax.swing.border.EmptyBorder;importjavax.swing.border.TitledBorder;importjavax.swing.event.TreeSelectionEvent;importjavax.swing.event.TreeSelectionListener;importjavax.swing.tree.DefaultMutableTreeNode;importjavax.swing.tree.TreePath;importjavax.swing.tree.TreeSelectionModel;importcom.sun.java.swing.plaf.nimbus.NimbusLookAndFeel;importcom.szss.bean.User;importcom.szss.panel.DepotPanel;importcom.szss.panel.DeptPanel;importcom.szss.panel.FeelWarePanel;importcom.szss.panel.JoinDepotPanel;importcom.szss.panel.MyJPanel;importcom.szss.panel.OutDepotPanel;importcom.szss.panel.PersonnelPanel;importcom.szss.panel.SellPanel;importcom.szss.panel.StockPanel;importcom.szss.panel.WarePanel;importcom.szss.util.Session;importcom.szss.widget.BGPanel;importcom.szss.widget.GlassButton;importcom.szss.widget.SmallScrollPanel;importjava.awt.Dimension;importjava.awt.GridLayout;importjavax.swing.ButtonGroup;importjavax.swing.ImageIcon;importjavax.swing.JLabel;importjavax.swing.JTree;importjavax.swing.JScrollPane;importjava.awt.event.ActionListener;importjava.awt.event.ActionEvent;public class RemoveButtomFrame extendsJFrame {privateMyJPanel contentPane;privateBGPanel backPanel;private SmallScrollPanel moduleButtonGroup = null;privateJTree tree;privateJPanel panel;
FeelWarePanel panelFeel= newFeelWarePanel();
JPanel panel_1= newJPanel();
JLabel fristLabel= new JLabel("基本档案管理");private BGPanel jPanel = null;private ButtonGroup buttonGroup = null;private GlassButton workSpaceButton = null;private GlassButton progressButton = null;private GlassButton bookProjectButton = null;private GlassButton chukuButton = null;private GlassButton personnelManagerButton = null;private GlassButton deptManagerButton = null;
JLabel label_1= new JLabel("您当前的位置是:");/*** Create the frame.*/
publicRemoveButtomFrame() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 934, 625);
contentPane= newMyJPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.add(getModuleButtonGroup());
setTitle("三只松鼠管理系统");
contentPane.setLayout(null);
setResizable(false);
JPanel clockpanel= newJPanel();
clockpanel.setBackground(new Color(255,175,175));
clockpanel.setBounds(10, 120, 248, 130);
contentPane.add(clockpanel);
clockpanel.setLayout(null);
JPanel panel_1= newJPanel();
panel_1.setBounds(0, 210, 276, 1);
clockpanel.add(panel_1);
panel_1.setLayout(null);
User user= Session.getUser(); //获取登录用户对象
String info = "
" + " 你 好:"+ "" + user.getUserName() + ""
+ " 欢 迎 登 录" + ""; //定义窗体显示内容
JLabel label= new JLabel(info); //定义显示指定内容的标签对象
label.setBackground(Color.yellow);
label.setBounds(70, 30, 128, 35);
clockpanel.add(label);
contentPane.add(getContentPanel());//在主窗体中添加
}privateBGPanel getContentPanel() {if (backPanel == null) {
backPanel= newBGPanel();
backPanel.setBackground(new Color(255,175,175));
backPanel.setSize(629, 416); //内容显示区主面板
backPanel.setLocation(279, 149);
backPanel.setLayout(null);
label_1.setHorizontalAlignment(SwingConstants.RIGHT);
label_1.setVerticalAlignment(SwingConstants.BOTTOM);
label_1.setBounds(38, 38, 96, 15);
backPanel.setBorder(createTitledBorder(null, "基本档案管理",
TitledBorder.DEFAULT_JUSTIFICATION,
TitledBorder.TOP,new Font("sansserif", Font.BOLD,12), new Color(59, 59, 59)));
backPanel.add(label_1);
fristLabel.setBounds(133, 38, 123, 15);
backPanel.add(fristLabel);
panel_1.setBounds(10, 63, 611, 343);
panel_1.setLayout(null);
backPanel.add(panel_1);
JScrollPane scrollPane= newJScrollPane();
panel_1.add(scrollPane);
JScrollPane scrollPane_1= newJScrollPane();
scrollPane_1.setBackground(new Color(255,175,175));
scrollPane_1.setBounds(0, 0, 138, 334);
panel_1.add(scrollPane_1);
DefaultMutableTreeNode rootNode= newDefaultMutableTreeNode("基本档案管理");
DefaultMutableTreeNode childNode1= newDefaultMutableTreeNode("供货商管理");
DefaultMutableTreeNode childNode2= newDefaultMutableTreeNode("销售商管理");
DefaultMutableTreeNode childNode3= newDefaultMutableTreeNode("货品档案管理");
DefaultMutableTreeNode childNode4= newDefaultMutableTreeNode("仓库管理");
rootNode.add(childNode1);
rootNode.add(childNode2);
rootNode.add(childNode3);
rootNode.add(childNode4);
tree= newJTree(rootNode);
scrollPane_1.setColumnHeaderView(tree);final JPanel sellPanel = newJPanel();
sellPanel.setBackground(new Color(255,175,175));
sellPanel.setBounds(138, 0, 473, 343);
sellPanel.setLayout(null);
panel_1.add(sellPanel);
tree.getSelectionModel().setSelectionMode(
TreeSelectionModel.SINGLE_TREE_SELECTION);
TreeSelectionModel treeSelectionModel=tree.getSelectionModel();
treeSelectionModel
.setSelectionMode(TreeSelectionModel.CONTIGUOUS_TREE_SELECTION);
tree.addTreeSelectionListener(newTreeSelectionListener() {
@Overridepublic voidvalueChanged(TreeSelectionEvent e) {if (!tree.isSelectionEmpty()) {
TreePath selectionPaths=tree.getSelectionPath();
Object path=selectionPaths.getLastPathComponent();
DefaultMutableTreeNode node=(DefaultMutableTreeNode) path;
String userObject=(String) node.getUserObject();
repaint();if (userObject.equals("供货商管理")) {
fristLabel.setText("供货商管理");
sellPanel.removeAll();
sellPanel.add(panelFeel.getMessage());
}else if (userObject.equals("销售商管理")) {
fristLabel.setText("销售商管理");
sellPanel.removeAll();
SellPanel sell= newSellPanel();
sellPanel.add(sell.getMessage());
repaint();
}else if (userObject.equals("货品档案管理")) {
fristLabel.setText("货品档案管理");
sellPanel.removeAll();
WarePanel warePanel= newWarePanel();
sellPanel.add(warePanel.getMessage());
repaint();
}else if (userObject.equals("仓库管理")) {
fristLabel.setText("仓库管理");
sellPanel.removeAll();
DepotPanel depotPanel= newDepotPanel();
sellPanel.add(depotPanel.getMessage());
repaint();
}
}
}
});
}returnbackPanel;
}privateSmallScrollPanel getModuleButtonGroup() {if (moduleButtonGroup == null) {
moduleButtonGroup= new SmallScrollPanel();//创建移动面板
moduleButtonGroup.setBounds(250, 20, 434, 68);
moduleButtonGroup.setOpaque(false);//将按钮组面板作为移动面板的视图
moduleButtonGroup.setViewportView(getJPanel());
moduleButtonGroup.getAlphaScrollPanel()
.setViewportView(getJPanel());//添加鼠标事件监听器
}returnmoduleButtonGroup;
}publicBGPanel getJPanel() {if (jPanel == null) {
GridLayout gridLayout= new GridLayout(); //定义网格布局管理器
gridLayout.setRows(1); //设置网格布局管理器的行数
gridLayout.setHgap(0); //设置组件间水平间距
gridLayout.setVgap(0); //设置组件间垂直间距
jPanel = new BGPanel(); //
//设置布局管理器
jPanel.setLayout(gridLayout);//设置初始大小
jPanel.setPreferredSize(new Dimension(400, 50));
jPanel.setOpaque(false);//添加按钮
jPanel.add(getWorkSpaceButton(), null);
jPanel.add(getProgressButton(),null);
jPanel.add(getrukuButton(),null);
jPanel.add(getchukuButton(),null);
jPanel.add(getPersonnelManagerButton(),null);
jPanel.add(getDeptManagerButton(),null);if (buttonGroup == null) {
buttonGroup= newButtonGroup();
}//把所有按钮添加到一个组控件中
buttonGroup.add(getProgressButton());
buttonGroup.add(getWorkSpaceButton());
buttonGroup.add(getrukuButton());
buttonGroup.add(getchukuButton());
buttonGroup.add(getPersonnelManagerButton());
buttonGroup.add(getDeptManagerButton());
}returnjPanel;
}//基本档案管理按钮
privateGlassButton getWorkSpaceButton() {if (workSpaceButton == null) {
workSpaceButton= newGlassButton();
workSpaceButton.setActionCommand("基本档案管理"); //设置按钮的动作命令
workSpaceButton.setIcon(newImageIcon(getClass().getResource("/com/szss/frame/buttonIcons/myWorkSpace.png"))); //定义按钮的初始化背景
ImageIcon icon = newImageIcon(getClass().getResource("/com/szss/frame/buttonIcons/myWorkSpace2.png")); //创建图片对象
workSpaceButton.setRolloverIcon(icon); //设置按钮的翻转图片
workSpaceButton.setSelectedIcon(icon); //设置按钮被选中时显示图片
workSpaceButton.setSelected(true);
workSpaceButton.addActionListener(new toolsButtonActionAdapter()); //按钮的监听器
}returnworkSpaceButton;
}//采购进货管理按钮
privateGlassButton getProgressButton() {if (progressButton == null) {
progressButton= newGlassButton();
progressButton.setActionCommand("采购进货");
progressButton.setText("");
progressButton.setIcon(newImageIcon(getClass().getResource("/com/szss/frame/buttonIcons/caigou1.png")));
ImageIcon icon= newImageIcon(getClass().getResource("/com/szss/frame/buttonIcons/caigou2.png"));
progressButton.setRolloverIcon(icon);
progressButton.setSelectedIcon(icon);
progressButton.addActionListener(newtoolsButtonActionAdapter());
}returnprogressButton;
}//仓库管理
privateGlassButton getrukuButton() {if (bookProjectButton == null) {
bookProjectButton= newGlassButton();
bookProjectButton.setActionCommand("仓库入库");//bookProjectButton.setText("图书计划");
ImageIcon icon = newImageIcon(getClass().getResource("/com/szss/frame/buttonIcons/ruku2.png"));
bookProjectButton.setSelectedIcon(icon);
bookProjectButton.setRolloverIcon(icon);
bookProjectButton.setIcon(newImageIcon(getClass().getResource("/com/szss/frame/buttonIcons/ruku1.png")));
bookProjectButton.addActionListener(newtoolsButtonActionAdapter());
}returnbookProjectButton;
}//仓库出库管理
privateGlassButton getchukuButton() {if (chukuButton == null) {
chukuButton= newGlassButton();
chukuButton.setActionCommand("仓库出库");
ImageIcon icon= newImageIcon(getClass().getResource("/com/szss/frame/buttonIcons/chuku1.png"));
chukuButton.setSelectedIcon(icon);
chukuButton.setRolloverIcon(icon);
chukuButton.setIcon(newImageIcon(getClass().getResource("/com/szss/frame/buttonIcons/chuku2.png")));
chukuButton.addActionListener(newtoolsButtonActionAdapter());
}returnchukuButton;
}//人员管理系统
privateGlassButton getPersonnelManagerButton() {if (personnelManagerButton == null) {
personnelManagerButton= newGlassButton();//personnelManagerButton.setText("人员管理");
personnelManagerButton.setActionCommand("查询及统计系统");//personnelManagerButton.setCursor(new//Cursor(Cursor.DEFAULT_CURSOR));
ImageIcon imageIcon = newImageIcon(getClass().getResource("/com/szss/frame/buttonIcons/person2.png"));
personnelManagerButton.setIcon(imageIcon);
ImageIcon icon= newImageIcon(getClass().getResource("/com/szss/frame/buttonIcons/person1.png"));
personnelManagerButton.setRolloverIcon(icon);
personnelManagerButton.setSelectedIcon(icon);
personnelManagerButton.setFocusPainted(false);
personnelManagerButton
.addActionListener(newtoolsButtonActionAdapter());
}returnpersonnelManagerButton;
}//部门管理系统
privateGlassButton getDeptManagerButton() {if (deptManagerButton == null) {
deptManagerButton= newGlassButton();
deptManagerButton.setActionCommand("查询及统计系统");//personnelManagerButton.setCursor(new//Cursor(Cursor.DEFAULT_CURSOR));
ImageIcon imageIcon = newImageIcon(getClass().getResource("/com/szss/frame/buttonIcons/deptButton.png"));
deptManagerButton.setIcon(imageIcon);
ImageIcon icon= newImageIcon(getClass().getResource("/com/szss/frame/buttonIcons/deptButton2.png"));
deptManagerButton.setRolloverIcon(icon);
deptManagerButton.setSelectedIcon(icon);
deptManagerButton.setFocusPainted(false);
deptManagerButton.addActionListener(newtoolsButtonActionAdapter());
}returndeptManagerButton;
}class toolsButtonActionAdapter implementsActionListener {
@Overridepublic voidactionPerformed(ActionEvent e) {if (e.getSource() ==workSpaceButton) {
backPanel.removeAll();
backPanel.add(label_1);
fristLabel.setBounds(133, 38, 123, 15);
backPanel.add(fristLabel);
panel_1.setBounds(10, 63, 611, 376);
backPanel.add(panel_1);
fristLabel.setText("基本档案管理");
repaint();
}if (e.getSource() ==progressButton) {
backPanel.removeAll();
backPanel.add(label_1);
fristLabel.setBounds(133, 38, 123, 15);
backPanel.add(fristLabel);
panel_1.setBounds(10, 63, 611, 386);
StockPanel stockPanl= newStockPanel();
fristLabel.setText("采购订货");
backPanel.add(stockPanl);
repaint();
}if (e.getSource() ==bookProjectButton) {
backPanel.removeAll();
backPanel.add(label_1);
fristLabel.setBounds(133, 38, 123, 15);
backPanel.add(fristLabel);
panel_1.setBounds(10, 63, 611, 386);
JoinDepotPanel joinPanel= newJoinDepotPanel();
backPanel.add(joinPanel);
fristLabel.setText("仓库入库");
repaint();
}if (e.getSource() ==chukuButton) {
backPanel.removeAll();
backPanel.add(label_1);
fristLabel.setBounds(133, 38, 123, 15);
backPanel.add(fristLabel);
panel_1.setBounds(10, 63, 611, 386);
OutDepotPanel outPanel= newOutDepotPanel();
backPanel.add(outPanel);
fristLabel.setText("仓库出库");
repaint();
}if (e.getSource() ==deptManagerButton) {
backPanel.removeAll();
backPanel.add(label_1);
fristLabel.setBounds(133, 38, 123, 15);
backPanel.add(fristLabel);
panel_1.setBounds(10, 63, 611, 386);
DeptPanel outPanel= newDeptPanel();
backPanel.add(outPanel);
fristLabel.setText("部门管理");
repaint();
}if (e.getSource() ==personnelManagerButton) {
backPanel.removeAll();
panel_1.setBounds(10, 63, 611, 386);
PersonnelPanel panel= newPersonnelPanel();
backPanel.add(panel);
repaint();
}
}
}
}