package UI;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Cursor;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.File;
import java.io.IOException;
import java.util.Calendar;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JSplitPane;
import javax.swing.JToolBar;
import javax.swing.Timer;
import tools.image_panel;
import tools.mytool;
public class main_ui extends JFrame implements ActionListener,MouseListener{
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
main_ui mu=new main_ui();
}
Image tileIcon,timebg,main_img, zhu_image,ip3_image,ip4_image,ip5_image,ip6_image,ip7_image,ip8_image,ip9_image;
JMenuBar jmb;
JMenu jm1,jm2,jm3,jm4,jm5,jm6;
JMenuItem jmm1,jmm2,jmm3,jmm4,jmm5;
ImageIcon jm1_icon1,jm1_icon2,jm1_icon3,jm1_icon4,jm1_icon5;
JToolBar jtb;
JButton jb1,jb2,jb3,jb4,jb5,jb6,jb7,jb8,jb9,jb10;
JPanel jp1,jp2,jp3,jp4,jp5,jp6,jp7,jp8,jp9;
JLabel timenow,jp6_1,jp6_2,jp6_3,jp6_4,jp6_5,jp6_6,jp6_7,jp6_8,jp8_1,jp8_2;
Timer time;
image_panel ip2;
CardLayout cl,cl2;
JSplitPane jsp1;
Cursor cursor;
public main_ui() throws IOException {
//创建一级菜单
jmb=new JMenuBar();
jm1=new JMenu("系统管理");
jm1.setFont(mytool.f1);
jm1_icon1=new ImageIcon("image/a7.png");
jmm1=new JMenuItem("切换用户",jm1_icon1);
jmm1.setFont(mytool.f2);
jmm2=new JMenuItem("切换到收款页面",jm1_icon1);
jmm2.setFont(mytool.f2);
jmm3=new JMenuItem("登陆管理",jm1_icon1);
jmm3.setFont(mytool.f2);
jmm4=new JMenuItem("万年历",jm1_icon1);
jmm4.setFont(mytool.f2);
jmm5=new JMenuItem("退出",jm1_icon1);
jmm5.setFont(mytool.f2);
jm1.add(jmm1);jm1.add(jmm2);
jm1.add(jmm3);jm1.add(jmm4);
jm1.add(jmm5);
jm2=new JMenu("人事管理");
jm2.setFont(mytool.f1);
jm3=new JMenu("菜单服务");
jm3.setFont(mytool.f1);
jm4=new JMenu("报表统计");
jm4.setFont(mytool.f1);
jm5=new JMenu("成本及库房");
jm5.setFont(mytool.f1);
jm6=new JMenu("帮助");
jm6.setFont(mytool.f1);
jmb.add(jm1);jmb.add(jm2);
jmb.add(jm3);jmb.add(jm4);
jmb.add(jm5);jmb.add(jm6);
//创建工具栏
jtb=new JToolBar();
jtb.setFloatable(false);
jm1_icon2=new ImageIcon("image/a8.png");
jb1=new JButton(jm1_icon2);
jb2=new JButton(jm1_icon2);
jb3=new JButton(jm1_icon2);
jb4=new JButton(jm1_icon2);
jb5=new JButton(jm1_icon2);
jb6=new JButton(jm1_icon2);
jb7=new JButton(jm1_icon2);
jb8=new JButton(jm1_icon2);
jb9=new JButton(jm1_icon2);
jb10=new JButton(jm1_icon2);
jtb.add(jb1);jtb.add(jb2);
jtb.add(jb3);jtb.add(jb4);
jtb.add(jb5);jtb.add(jb6);
jtb.add(jb7);jtb.add(jb8);
jtb.add(jb9);jtb.add(jb10);
//处理中间布局
cursor=new Cursor(Cursor.HAND_CURSOR);
jp6=new JPanel(new BorderLayout());
try {
main_img=ImageIO.read(new File("image/a12.jpg"));
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
ip2=new image_panel(main_img);
ip2.setLayout(new GridLayout(8,1));
jp6_1=new JLabel("餐 饮 管 理",new ImageIcon("image/a8.png"),0);
jp6_1.setFont(mytool.f3);
ip2.add(jp6_1);
jp6_2=new JLabel("登 陆 管 理",new ImageIcon("image/a8.png"),0);
jp6_2.setFont(mytool.f3);
jp6_2.addMouseListener(this);
jp6_2.setCursor(cursor);
jp6_2.setEnabled(false);
ip2.add(jp6_2);
jp6_3=new JLabel("人 事 管 理",new ImageIcon("image/a8.png"),0);
jp6_3.setFont(mytool.f3);
jp6_3.addMouseListener(this);
jp6_3.setCursor(cursor);
jp6_3.setEnabled(false);
ip2.add(jp6_3);
jp6_4=new JLabel("菜 谱 价 格",new ImageIcon("image/a8.png"),0);
jp6_4.setFont(mytool.f3);
jp6_4.addMouseListener(this);
jp6_4.setCursor(cursor);
jp6_4.setEnabled(false);
ip2.add(jp6_4);
jp6_5=new JLabel("报 表 统 计",new ImageIcon("image/a8.png"),0);
jp6_5.setFont(mytool.f3);
jp6_5.addMouseListener(this);
jp6_5.setCursor(cursor);
jp6_5.setEnabled(false);
ip2.add(jp6_5);
jp6_6=new JLabel("成本及库 房",new ImageIcon("image/a8.png"),0);
jp6_6.setFont(mytool.f3);
jp6_6.addMouseListener(this);
jp6_6.setCursor(cursor);
jp6_6.setEnabled(false);
ip2.add(jp6_6);
jp6_7=new JLabel("系 统 设 置",new ImageIcon("image/a8.png"),0);
jp6_7.setFont(mytool.f3);
jp6_7.addMouseListener(this);
jp6_7.setCursor(cursor);
jp6_7.setEnabled(false);
ip2.add(jp6_7);
jp6_8=new JLabel("动 画 帮 助",new ImageIcon("image/a8.png"),0);
jp6_8.setFont(mytool.f3);
jp6_8.addMouseListener(this);
jp6_8.setCursor(cursor);
jp6_8.setEnabled(false);
ip2.add(jp6_8);
jp6.add(ip2);
jp7=new JPanel(new BorderLayout());
cl=new CardLayout();
jp8=new JPanel(cl);
jp8_1=new JLabel(new ImageIcon("image/a16.png"));
jp8_2=new JLabel(new ImageIcon("image/a16.png"));
jp8.add(jp8_1,"0");
jp8.add(jp8_2,"1");
cl2=new CardLayout();
jp9=new JPanel(cl2);
try {
zhu_image=ImageIO.read(new File("image/a17.jpg"));
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
ip3_image=ImageIO.read(new File("image/j1.jpg"));
ip4_image=ImageIO.read(new File("image/j2.jpg"));
ip5_image=ImageIO.read(new File("image/j3.jpg"));
ip6_image=ImageIO.read(new File("image/j4.jpg"));
ip7_image=ImageIO.read(new File("image/j5.jpg"));
ip8_image=ImageIO.read(new File("image/j6.jpg"));
ip9_image=ImageIO.read(new File("image/j7.jpg"));
image_panel ip3=new image_panel(zhu_image);
image_panel ip4=new image_panel(ip4_image);
image_panel ip5=new image_panel(ip5_image);
image_panel ip6=new image_panel(ip6_image);
image_panel ip7=new image_panel(ip7_image);
image_panel ip8=new image_panel(ip8_image);
image_panel ip9=new image_panel(ip9_image);
image_panel ip10=new image_panel(ip3_image);
//image_panel ip10=new image_panel(zhu_image);
jp9.add(ip3,"0");
jp9.add(ip4,"1");
EmpInfo emp=new EmpInfo();
//jp9.add(ip5,"2");
jp9.add(emp,"2");
jp9.add(ip6,"3");
jp9.add(ip7,"4");
jp9.add(ip8,"5");
jp9.add(ip9,"6");
jp9.add(ip10,"7");
jp7.add(jp8,"West");
jp7.add(jp9,"Center");
//做一个拆分窗口,
jsp1=new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,true,jp6,jp7);
jsp1.setDividerLocation(150);
jsp1.setDividerSize(0);
//状态栏
jp5=new JPanel(new BorderLayout());
time=new Timer(1000,this);//每隔1s触发actionperformed
time.start();
timenow=new JLabel(Calendar.getInstance().getTime().toGMTString()+" ");
timenow.setFont(mytool.f1);
try {
timebg=ImageIO.read(new File("image/a10.png"));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
image_panel ip1=new image_panel(timebg);
ip1.setLayout(new BorderLayout());
ip1.add(timenow,"East");
jp5.add(ip1);
try {
tileIcon=ImageIO.read(new File("image/a1.png"));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
int w=Toolkit.getDefaultToolkit().getScreenSize().width;
int h=Toolkit.getDefaultToolkit().getScreenSize().height;
this.setJMenuBar(jmb);
this.add(jtb,"North");
this.add(jsp1);
this.add(jp5,"South");
this.setIconImage(tileIcon);
this.setTitle("满汉楼餐饮管理系统");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setSize(w,h-45);
this.setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
this.timenow.setText(Calendar.getInstance().getTime().toString()+" ");
}
@Override
public void mouseClicked(MouseEvent e) {
// TODO Auto-generated method stub
if(e.getSource()==jp6_2){
cl2.show(jp9, "1");
}
else if(e.getSource()==jp6_3){
cl2.show(jp9, "2");
}
else if(e.getSource()==jp6_4){
cl2.show(jp9, "3");
}
else if(e.getSource()==jp6_5){
cl2.show(jp9, "4");
}
else if(e.getSource()==jp6_6){
cl2.show(jp9, "5");
}
else if(e.getSource()==jp6_7){
cl2.show(jp9, "6");
}
else if(e.getSource()==jp6_8){
cl2.show(jp9, "7");
}
}
@Override
public void mousePressed(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseReleased(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseEntered(MouseEvent e) {
// TODO Auto-generated method stub
if(e.getSource()==jp6_2){
jp6_2.setEnabled(true);
}
else if(e.getSource()==jp6_3){
jp6_3.setEnabled(true);
}
else if(e.getSource()==jp6_4){
jp6_4.setEnabled(true);
}
else if(e.getSource()==jp6_5){
jp6_5.setEnabled(true);
}
else if(e.getSource()==jp6_6){
jp6_6.setEnabled(true);
}
else if(e.getSource()==jp6_7){
jp6_7.setEnabled(true);
}
else if(e.getSource()==jp6_8){
jp6_8.setEnabled(true);
}
}
@Override
public void mouseExited(MouseEvent e) {
// TODO Auto-generated method stub
if(e.getSource()==jp6_2){
jp6_2.setEnabled(false);
}
else if(e.getSource()==jp6_3){
jp6_3.setEnabled(false);
}
else if(e.getSource()==jp6_4){
jp6_4.setEnabled(false);
}
else if(e.getSource()==jp6_5){
jp6_5.setEnabled(false);
}
else if(e.getSource()==jp6_6){
jp6_6.setEnabled(false);
}
else if(e.getSource()==jp6_7){
jp6_7.setEnabled(false);
}
else if(e.getSource()==jp6_8){
jp6_8.setEnabled(false);
}
}
}