⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainframe.java

📁 java在线商店的源代码。编写十分规范的哦
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/**
 * Copyright (c) 1996-2004 Borland Software Corporation.  All Rights Reserved.
 * 
 * This SOURCE CODE FILE, which has been provided by Borland Software as part
 * of a Borland Software product for use ONLY by licensed users of the product,
 * includes CONFIDENTIAL and PROPRIETARY information of Borland Software.  
 *
 * USE OF THIS SOFTWARE IS GOVERNED BY THE TERMS AND CONDITIONS 
 * OF THE LICENSE STATEMENT AND LIMITED WARRANTY FURNISHED WITH
 * THE PRODUCT.
 *
 * IN PARTICULAR, YOU WILL INDEMNIFY AND HOLD BORLAND SOFTWARE, ITS
 * RELATED COMPANIES AND ITS SUPPLIERS, HARMLESS FROM AND AGAINST ANY
 * CLAIMS OR LIABILITIES ARISING OUT OF THE USE, REPRODUCTION, OR
 * DISTRIBUTION OF YOUR PROGRAMS, INCLUDING ANY CLAIMS OR LIABILITIES
 * ARISING OUT OF OR RESULTING FROM THE USE, MODIFICATION, OR
 * DISTRIBUTION OF PROGRAMS OR FILES CREATED FROM, BASED ON, AND/OR
 * DERIVED FROM THIS SOURCE CODE FILE.
 */
//------------------------------------------------------------------------------
// Copyright (c) 1996-2004 Borland Software Corporation.  All Rights Reserved.
//------------------------------------------------------------------------------

package com.borland.samples.orderentry;

import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;

/**
 * MainFrame is the main window of the Cliffhanger Application.
 * This class implements a button menu to navigate to other
 * functional areas of the application.
 * During instantiation of this class, an attempt to make the database
 * connection is made, and shuts down the application if the connection fails.
 */
public class MainFrame extends JFrame {
  JPanel contentPane;
  BorderLayout borderLayout1 = new BorderLayout();
  JPanel jPanel1 = new JPanel();
  JMenuBar jMenuBar1 = new JMenuBar();
  JMenu jMenuFile = new JMenu();
  JMenuItem jMenuFileExit = new JMenuItem();
  JMenu jMenuHelp = new JMenu();
  JMenuItem jMenuHelpAbout = new JMenuItem();
  JLabel statusBar = new JLabel();
  JPanel jPanel2 = new JPanel();
  GridBagLayout gridBagLayout1 = new GridBagLayout();
  JButton btnOrders = new JButton();
  JButton btnCustomers = new JButton();
  JButton btnProducts = new JButton();
  JButton btnCategories = new JButton();
  JButton btnExit = new JButton();
  JLabel imageLogo = new JLabel();
  BorderLayout borderLayout2 = new BorderLayout();
  BorderLayout borderLayout3 = new BorderLayout();
  JPopupMenu pumOrder = new JPopupMenu();
  JMenuItem pumNewOrder = new JMenuItem();
  JMenuItem pumFindOrder = new JMenuItem();
  JPopupMenu pumCustomer = new JPopupMenu();
  JPopupMenu pumProduct = new JPopupMenu();
  JMenuItem pumNewCustomer = new JMenuItem();
  JMenuItem pumFindCustomer = new JMenuItem();
  JMenuItem pumNewProduct = new JMenuItem();
  JMenuItem pumFindProduct = new JMenuItem();
  ResourceBundle res = Res.getBundle("com.borland.samples.orderentry.Res");

  /**
   * Construct the frame
   */
  public MainFrame() {
    try {
      jbInit();
      initData();
    }
    catch (Exception e) {
      e.printStackTrace();
    };
  }

  /**
   * Component initialization
   *
   * @throws Exception
   * return  void
   */
  private void jbInit() throws Exception{
    contentPane = (JPanel) this.getContentPane();
    contentPane.setLayout(borderLayout1);
    this.setTitle(res.getString("MF_Cliffhanger_Title"));
    this.addWindowListener(new java.awt.event.WindowAdapter() {
      public void windowClosing(WindowEvent e) {
        this_windowClosing(e);
      }
    });
    jPanel1.setLayout(borderLayout3);
    jMenuFile.setText(res.getString("MF_File"));
    jMenuFileExit.setText(res.getString("MF_Exit"));
    jMenuFileExit.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
        fileExit_actionPerformed(e);
      }
    });
    jMenuHelp.setText(res.getString("MF_Help"));
    jMenuHelpAbout.setText(res.getString("MF_About"));
    btnOrders.setActionCommand(res.getString("MF_Orders"));
    btnOrders.setHorizontalAlignment(SwingConstants.LEFT);
    btnOrders.setIcon(new ImageIcon(this.getClass().getResource("images/orders.gif")));
    btnOrders.setText(res.getString("MF_Orders"));
    btnOrders.addMouseListener(new java.awt.event.MouseAdapter() {
      public void mouseEntered(MouseEvent e) {
        btnOrders_mouseEntered(e);
      }
      public void mouseExited(MouseEvent e) {
        btnOrders_mouseExited(e);
      }
    });
    btnOrders.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
        btnOrders_actionPerformed(e);
      }
    });
    btnCustomers.setActionCommand("Customers");
    btnCustomers.setHorizontalAlignment(SwingConstants.LEFT);
    btnCustomers.setIcon(new ImageIcon(this.getClass().getResource("images/customers.gif")));
    btnCustomers.setText(res.getString("MF_Customers"));
    btnCustomers.addMouseListener(new java.awt.event.MouseAdapter() {
      public void mouseEntered(MouseEvent e) {
        btnCustomers_mouseEntered(e);
      }
      public void mouseExited(MouseEvent e) {
        btnCustomers_mouseExited(e);
      }
    });
    btnCustomers.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
        btnCustomers_actionPerformed(e);
      }
    });
    btnProducts.setActionCommand(res.getString("MF_Products"));
    btnProducts.setHorizontalAlignment(SwingConstants.LEFT);
    btnProducts.setIcon(new ImageIcon(this.getClass().getResource("images/products.gif")));
    btnProducts.setText(res.getString("MF_Products"));
    btnProducts.addMouseListener(new java.awt.event.MouseAdapter() {
      public void mouseEntered(MouseEvent e) {
        btnProducts_mouseEntered(e);
      }
      public void mouseExited(MouseEvent e) {
        btnProducts_mouseExited(e);
      }
    });
    btnProducts.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
        btnProducts_actionPerformed(e);
      }
    });
    btnCategories.setActionCommand("");
    btnCategories.setHorizontalAlignment(SwingConstants.LEFT);
    btnCategories.setIcon(new ImageIcon(this.getClass().getResource("images/categories.gif")));
    btnCategories.setText(res.getString("MF_Categories"));
    btnCategories.addMouseListener(new java.awt.event.MouseAdapter() {
      public void mouseEntered(MouseEvent e) {
        btnCategories_mouseEntered(e);
      }
      public void mouseExited(MouseEvent e) {
        btnCategories_mouseExited(e);
      }
    });
    btnCategories.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
        btnCategories_actionPerformed(e);
      }
    });
    btnExit.setActionCommand("");
    btnExit.setHorizontalAlignment(SwingConstants.LEFT);
    btnExit.setIcon(new ImageIcon(this.getClass().getResource("images/exit.gif")));
    btnExit.setText(res.getString("MF_Exit"));
    btnExit.addMouseListener(new java.awt.event.MouseAdapter() {
      public void mouseEntered(MouseEvent e) {
        btnExit_mouseEntered(e);
      }
      public void mouseExited(MouseEvent e) {
        btnExit_mouseExited(e);
      }
    });
    btnExit.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
        btnExit_actionPerformed(e);
      }
    });
    imageLogo.setHorizontalAlignment(SwingConstants.CENTER);
    imageLogo.setVerticalAlignment(SwingConstants.CENTER);
    imageLogo.setIcon(new ImageIcon(this.getClass().getResource("images/logo.gif")));
    pumNewOrder.setText(res.getString("MF_New_Order"));
    pumNewOrder.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
        pumNewOrder_actionPerformed(e);
      }
    });
    pumFindOrder.setText(res.getString("MF_Find_Order"));
    pumFindOrder.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
        pumFindOrder_actionPerformed(e);
      }
    });
    pumNewCustomer.setText(res.getString("MF_New_Customer"));
    pumNewCustomer.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
        pumNewCustomer_actionPerformed(e);
      }
    });
    pumFindCustomer.setText(res.getString("MF_Find_Customer"));
    pumFindCustomer.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
        pumFindCustomer_actionPerformed(e);
      }
    });
    pumNewProduct.setText(res.getString("MF_New_Product"));
    pumNewProduct.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
        pumNewProduct_actionPerformed(e);
      }
    });
    pumFindProduct.setText(res.getString("MF_Find_Product"));
    pumFindProduct.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
        pumFindProduct_actionPerformed(e);
      }
    });
    jPanel2.setLayout(gridBagLayout1);
    jMenuHelpAbout.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
        helpAbout_actionPerformed(e);
      }
    });
    jMenuFile.add(jMenuFileExit);
    jMenuHelp.add(jMenuHelpAbout);
    jMenuBar1.add(jMenuFile);
    jMenuBar1.add(jMenuHelp);
    this.setJMenuBar(jMenuBar1);
    statusBar.setText(" ");
    statusBar.setOpaque(true);
    contentPane.add(statusBar, BorderLayout.SOUTH);
    contentPane.add(jPanel1, BorderLayout.CENTER);
    jPanel1.add(imageLogo, BorderLayout.CENTER);
    contentPane.add(jPanel2, BorderLayout.WEST);
    jPanel2.add(btnOrders, new GridBagConstraints(0, 1, 1, 1, 100.0, 100.0
            ,GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 70, 0));
    jPanel2.add(btnCustomers, new GridBagConstraints(0, 2, 1, 1, 100.0, 100.0
            ,GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
    jPanel2.add(btnProducts, new GridBagConstraints(0, 3, 1, 1, 100.0, 100.0
            ,GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
    jPanel2.add(btnCategories, new GridBagConstraints(0, 4, 1, 1, 100.0, 100.0
            ,GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
    jPanel2.add(btnExit, new GridBagConstraints(0, 5, 1, 1, 100.0, 100.0
            ,GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
    pumOrder.add(pumNewOrder);
    pumOrder.add(pumFindOrder);
    pumCustomer.add(pumNewCustomer);
    pumCustomer.add(pumFindCustomer);
    pumProduct.add(pumNewProduct);
    pumProduct.add(pumFindProduct);

  }

  /**
   * Instantiate a local instance of DataModule1 to
   * Connect to the database which will prompt
   * the user to login.
   * This way, the user will be prompted to login
   * only at startup (when the main form is created).
   */
  private void initData() {
    DataModule1 dm = DataModule1.getDataModule();
    try {
      dm.dbConnect();
    }
    catch (Exception ex) {
      // ex.printStackTrace();
      // If the user fails to connect to the database
      // show the error message and exit the program.
      String msg = res.getString("MF_DBConnect_Failed");
      JOptionPane.showMessageDialog(this,
                                    msg,
                                    res.getString("MF_Error"),
                                    JOptionPane.ERROR_MESSAGE);
      System.exit(0);
    }
  }

  /**
   * Menu File | Exit action performed event handler Close the applcation.
   *
   * @param e ActionEvent
   * return  void
   */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -