JF_main.java
资源名称:Appjxc.rar [点击查看]
上传用户:whbcdz
上传日期:2008-08-04
资源大小:7683k
文件大小:10k
源码类别:
JavaScript
开发平台:
Java
- package appjxc.view;
- import java.awt.BorderLayout;
- import java.awt.Dimension;
- import javax.swing.JFrame;
- import javax.swing.JPanel;
- import javax.swing.*;
- import javax.swing.border.*;
- import appjxc.constrol.MenuBarEvent;
- import java.awt.Font;
- import java.awt.SystemColor;
- import java.awt.Toolkit;
- import java.awt.Color;
- import java.awt.event.ActionListener;
- import java.awt.event.ActionEvent;
- public class JF_main extends JFrame {
- JPanel contentPane;
- BorderLayout borderLayout1 = new BorderLayout();
- public static JDesktopPane desktop = new JDesktopPane();
- //自定义事件类处理
- MenuBarEvent _MenuBarEvent = new MenuBarEvent();
- JMenuBar jMenuBarMain = new JMenuBar();
- JToolBar jToolBarMain = new JToolBar();
- Border border1;
- JLabel jLabel1 = new JLabel();
- Border border2;
- public JF_main() {
- try {
- setDefaultCloseOperation(EXIT_ON_CLOSE);
- //根据两个方法buildMenu()和buildToolBar()建立菜单和工具栏
- BuildMenuBar();
- BuildToolBar();
- jbInit();
- loadBackgroundImage();
- } catch (Exception exception) {
- exception.printStackTrace();
- }
- }
- /**
- * Component initialization.
- *
- * @throws java.lang.Exception
- */
- private void jbInit() throws Exception {
- contentPane = (JPanel) this.getContentPane();
- border1 = new EtchedBorder(EtchedBorder.RAISED, Color.white, Color.red);
- border2 = BorderFactory.createLineBorder(new Color(255, 55, 166), 1);
- contentPane.setLayout(borderLayout1);
- jMenuBarMain.setFont(new Font("宋体", 0, 12));
- jLabel1.setFont(new java.awt.Font("新宋体", 0, 12));
- jLabel1.setForeground(new Color(255, 104, 69));
- jLabel1.setBorder(border2);
- _MenuBarEvent.setDeskTop(this.desktop);
- jToolBarMain.setBorder(border1);
- this.setJMenuBar(jMenuBarMain);
- this.setResizable(false);
- jToolBarMain.setFloatable(false);
- desktop.setBackground(SystemColor.desktop);
- contentPane.add(jToolBarMain, BorderLayout.NORTH);
- contentPane.add(desktop, BorderLayout.CENTER);
- contentPane.add(jLabel1, BorderLayout.SOUTH);
- Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
- Dimension frameSize = getSize();
- if (frameSize.height > screenSize.height) {
- frameSize.height = screenSize.height;
- }
- if (frameSize.width > screenSize.width) {
- frameSize.width = screenSize.width;
- }
- setLocation((screenSize.width - frameSize.width) / 2,
- (screenSize.height - frameSize.height) / 2);
- setVisible(true);
- this.setSize(new Dimension(900, 700));
- setTitle("医药进销存管理系统");
- }
- protected void loadBackgroundImage(){
- ImageIcon icon = new ImageIcon(".\images\main.jpg");
- //ImageIcon icon = new ImageIcon(JF_main.class.getResource("main_bg.jpg"));
- JLabel jl = new JLabel(icon);
- jl.setBounds(0,0,icon.getIconWidth(),icon.getIconHeight());
- desktop.add(jl,new Integer(Integer.MIN_VALUE));
- //desktop.add(jl,BorderLayout.CENTER);
- }
- private void BuildMenuBar(){
- JMenu[] _jMenu = {new JMenu("【基本信息】"), new JMenu("【业务管理】"),
- new JMenu("【业务查询】"), new JMenu("【用户管理】"),
- new JMenu("【系统管理】")};
- /*设置菜单相目JMenuItem元素*/
- JMenuItem[] _jMenuItem0 = {new JMenuItem("【药品情况】"),
- new JMenuItem("【客户情况】"),
- new JMenuItem("【供应商情况】")};
- String[] _jMenuItem0Name = {"JF_view_medicine", "JF_view_client","JF_view_gys"};
- JMenuItem[] _jMenuItem1 = {new JMenuItem("【药品采购】"),
- new JMenuItem("【药品销售】"),
- new JMenuItem("【库存盘点】"),
- new JMenuItem("【销售退货】"),
- new JMenuItem("【客户回款】")};
- String[] _jMenuItem1Name = {"JF_view_buy", "JF_view_sell","JF_view_stock", "JF_view_xstk","JF_view_hkgl"};
- JMenuItem[] _jMenuItem3 = {new JMenuItem("【增加用户】"),
- new JMenuItem("【用户维护】")};
- String[] _jMenuItem3Name = {"sys_user_add", "sys_user_modify"};
- JMenuItem[] _jMenuItem4 = {
- new JMenuItem("【系统退出】")};//new JMenuItem("【重新登陆】"),
- String[] _jMenuItem4Name = {"JB_EXIT"};//"JB_LOGIN",
- JMenuItem[] _jMenuItem2 = {new JMenuItem("【基本信息】"),
- new JMenuItem("【入库明细】"),
- new JMenuItem("【销售明细】"),
- new JMenuItem("【回款信息】")};
- //new JMenuItem("【退库信息】")};
- String[] _jMenuItem2Name = {"JF_view_query_jbqk", "JF_view_query_rkqk", "JF_view_query_kcmx_ck",
- "JF_view_query_kcmx_hk", ""};
- /*设置菜单、菜单项字体风格*/
- Font _MenuItemFont = new Font("宋体", 0, 12);
- for (int i = 0; i < _jMenu.length; i++) {
- _jMenu[i].setFont(_MenuItemFont);
- jMenuBarMain.add(_jMenu[i]);
- }
- for (int j = 0; j < _jMenuItem0.length; j++) {
- _jMenuItem0[j].setFont(_MenuItemFont);
- final String EventName1 = _jMenuItem0Name[j];
- // _jMenuItem0[j].addActionListener(_MenuBarEvent);
- _jMenuItem0[j].addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- _MenuBarEvent.setEventName(EventName1);
- _MenuBarEvent.actionPerformed(e);
- }
- });
- _jMenu[0].add(_jMenuItem0[j]);
- if (j == 1) {
- _jMenu[0].addSeparator();
- }
- }
- for (int j = 0; j < _jMenuItem1.length; j++) {
- _jMenuItem1[j].setFont(_MenuItemFont);
- final String EventName1 = _jMenuItem1Name[j];
- _jMenuItem1[j].addActionListener(_MenuBarEvent);
- _jMenuItem1[j].addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- _MenuBarEvent.setEventName(EventName1);
- }
- });
- _jMenu[1].add(_jMenuItem1[j]);
- if (j == 1) {
- _jMenu[1].addSeparator();
- }
- if (j == 2) {
- _jMenu[1].addSeparator();
- }
- }
- for (int j = 0; j < _jMenuItem2.length; j++) {
- _jMenuItem2[j].setFont(_MenuItemFont);
- final String EventName2 = _jMenuItem2Name[j];
- _jMenuItem2[j].addActionListener(_MenuBarEvent);
- _jMenuItem2[j].addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- _MenuBarEvent.setEventName(EventName2);
- // _MenuBarEvent.getName();
- }
- });
- _jMenu[2].add(_jMenuItem2[j]);
- if ((j == 0 )||(j==2)) {
- _jMenu[2].addSeparator();
- }
- }
- for (int j = 0; j < _jMenuItem3.length; j++) {
- _jMenuItem3[j].setFont(_MenuItemFont);
- final String EventName3 = _jMenuItem3Name[j];
- _jMenuItem3[j].addActionListener(_MenuBarEvent);
- _jMenuItem3[j].addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- _MenuBarEvent.setEventName(EventName3);
- // _MenuBarEvent.getName();
- }
- });
- _jMenu[3].add(_jMenuItem3[j]);
- if (j == 0) {
- _jMenu[3].addSeparator();
- }
- }
- for (int j = 0; j < _jMenuItem4.length; j++) {
- _jMenuItem4[j].setFont(_MenuItemFont);
- final String EventName4 = _jMenuItem4Name[j];
- _jMenuItem4[j].addActionListener(_MenuBarEvent);
- _jMenuItem4[j].addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- _MenuBarEvent.setEventName(EventName4);
- // _MenuBarEvent.getName();
- }
- });
- _jMenu[4].add(_jMenuItem4[j]);
- }
- }
- private void BuildToolBar(){
- JToolBar toolbar = new JToolBar();
- //String ImageName[] = {"借出管理.gif","移动管理.gif","维修管理.gif","折旧管理.gif","报表管理.gif","增加.gif","删除.gif","修改.gif","打印.gif","查询.gif","刷新.gif","退出.gif"};
- String ImageName[] = {"药品录入.gif","供应商录入.gif","药品采购.gif","药品销售.GIF","库存盘点.GIF",
- "销售退货.GIF","客户回款.GIF","基本查询.GIF","入库明细.GIF","销售明细.GIF","用户管理.GIF","系统退出.GIF"};
- String TipString[] = {"药品录入","供应商录入","药品采购","药品销售","库存盘点",
- "销售退货","客户回款","基本查询","入库明细","销售明细","用户管理","系统退出"};
- String ComandString[] = {"JF_view_medicine","JF_view_gys","JF_view_buy", "JF_view_sell","JF_view_stock",
- "JF_view_xstk","JF_view_hkgl","JF_view_query_jbqk", "JF_view_query_rkqk",
- "JF_view_query_kcmx_ck","sys_user_modify","JB_EXIT"};
- for(int i = 0 ; i < ComandString.length; i++){
- JButton jb = new JButton();
- // ImageIcon image = new ImageIcon(JF_main.class.getResource(ImageName[i]));
- ImageIcon image = new ImageIcon(".\images\" + ImageName[i]);
- jb.setIcon(image);
- jb.setToolTipText(TipString[i]);
- jb.setActionCommand(ComandString[i]);
- jb.addActionListener(_MenuBarEvent);
- jToolBarMain.add(jb);
- }
- }
- private JMenuBar buildmenu(){
- JMenuBar jMenuBar = new JMenuBar();
- Font _menuFont = new Font("宋体", 0, 12);
- JMenu jMenu = new JMenu("参数设置") ;
- jMenuBar.add(jMenu);
- return jMenuBar;
- }
- }