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

📄 findframe.java

📁 java在线商店的源代码。编写十分规范的哦
💻 JAVA
字号:
/**
 * 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.*;
import com.borland.dbswing.*;
import com.borland.dx.dataset.*;

/**
 * FindFrame is the JFrame class that is used as a base class from
 * which the other Find forms are inherited. This find form allows users
 * to lookup orders, customers, or products by searching on a value for
 * a single column in the respective dataset. A table displays all the records
 * for the respective datasets, and the table will try to find the closet
 * matching record as the user types in the search value.
 */
public class FindFrame extends JFrame {
  private static FindFrame myFindFrame;
  JPanel contentPane;
  JPanel jPanel1 = new JPanel();
  JdbTable jdbTable1 = new JdbTable();
  JdbComboBox jdbComboBox1 = new JdbComboBox();
  JLabel jLabel1 = new JLabel();
  JLabel jLabel2 = new JLabel();
  JPanel jPanel2 = new JPanel();
  JPanel jPanel3 = new JPanel();
  JButton btnClose = new JButton();
  JButton btnGoto = new JButton();
  BorderLayout borderLayout2 = new BorderLayout();
  GridBagLayout gridBagLayout1 = new GridBagLayout();
  GridBagLayout gridBagLayout2 = new GridBagLayout();
  BorderLayout borderLayout3 = new BorderLayout();
  JdbNavField jdbNavField1 = new JdbNavField();
  JdbLabel imageLabel1 = new JdbLabel();
  JdbStatusLabel jdbStatusLabel1 = new JdbStatusLabel();
  JScrollPane jScrollPane1 = new JScrollPane();
  ResourceBundle res = Res.getBundle("com.borland.samples.orderentry.Res");

  /**
   * Although the constructor is public, it is not the intent to instantiate
   * an object of this base class. Rather, to create the specialized FindFrame
   * object, the static getXXXFindFrame() method of the descendant class
   * should be called.
   *
   * This constructor is made public so that the controls in this base class
   * can be displayed when designing any descendant class. Another requirement
   * so that the controls in the parent frame can be displayed is that the
   * class file of the parent file must have been generated before displaying
   * the descendant frame in the design view.
   */
  public FindFrame() {
    try {
      jbInit();
    }
    catch (Exception e) {
      e.printStackTrace();
    };
  }

  /**
   * Method generated and maintained by JBuilder designer to initialize control
   * properties.
   *
   * @throws Exception
   * return  void
   */
  private void jbInit() throws Exception{
    contentPane = (JPanel) this.getContentPane();
    this.setSize(new Dimension(500, 350));
    this.setTitle(res.getString("FF_Find"));
    this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    contentPane.setLayout(borderLayout3);
    jPanel1.setLayout(borderLayout2);
    jdbTable1.setEditable(false);
    jdbComboBox1.addItemListener(new java.awt.event.ItemListener() {
      public void itemStateChanged(ItemEvent e) {
        jdbComboBox1_itemStateChanged(e);
      }
    });
    jLabel1.setText(res.getString("FF_Field"));
    jLabel2.setText(res.getString("FF_Value"));
    jdbNavField1.addKeyListener(new java.awt.event.KeyAdapter() {
      public void keyPressed(KeyEvent e) {
        jdbNavField1_keyPressed(e);
      }
    });
    jPanel2.setLayout(gridBagLayout2);
    jPanel3.setLayout(gridBagLayout1);
    btnClose.setText(res.getString("FF_Close"));
    btnClose.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
        btnClose_actionPerformed(e);
      }
    });
    btnGoto.setText(res.getString("FF_Go_To"));
    imageLabel1.setHorizontalAlignment(SwingConstants.CENTER);
    imageLabel1.setIcon(new ImageIcon(this.getClass().getResource("images/findBanner.jpg")));
    btnGoto.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
        btnGoto_actionPerformed(e);
      }
    });
    jdbStatusLabel1.setOpaque(true);
    jScrollPane1.setOpaque(true);
    contentPane.add(jPanel1, BorderLayout.NORTH);
    jPanel1.add(jPanel2, BorderLayout.CENTER);
    jPanel2.add(jdbComboBox1, new GridBagConstraints(1, 0, 2, 1, 100.0, 0.0
            ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 5), 0, 0));
    jPanel2.add(jLabel1, new GridBagConstraints(0, 0, 1, 1, 10.0, 50.0
            ,GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 10, 1, 0), 0, 0));
    jPanel2.add(jLabel2, new GridBagConstraints(0, 1, 1, 1, 10.0, 50.0
            ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 10, 5, 0), 0, 0));
    jPanel2.add(jdbNavField1, new GridBagConstraints(1, 1, 2, 1, 100.0, 0.0
            ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 5), 206, 0));
    jPanel1.add(jPanel3, BorderLayout.EAST);
    jPanel3.add(btnClose, new GridBagConstraints(0, 0, 1, 1, 100.0, 100.0
            ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(4, 10, 4, 4), 50, 0));
    jPanel3.add(btnGoto, new GridBagConstraints(0, 1, 1, 1, 100.0, 100.0
            ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(4, 10, 4, 4), 0, 0));
    jPanel1.add(imageLabel1, BorderLayout.NORTH);
    jScrollPane1.getViewport().add(jdbTable1);
    contentPane.add(jScrollPane1, BorderLayout.CENTER);
    contentPane.add(jdbStatusLabel1, BorderLayout.SOUTH);
  }

  /**
   * Class method to access the singleton instance of the class
   *
   * @return FindFrame
   * return  void
   */
  public static FindFrame getFindFrame() {
    if (myFindFrame == null)
      myFindFrame = new FindFrame();

    return myFindFrame;
  }

  /**
   * When the Go To button is clicked, the concrete Find forms should override
   * this event handler to show the appropriate form for the record selected.
   *
   * @param e ActionEvent
   * return  void
   */
  protected void btnGoto_actionPerformed(ActionEvent e) {
  }

  /**
   * The itemStateChanged event is triggered when the user selects a new item
   * off the choiceControl's drop down list of possible fields to search on.
   * Reset the text property of the locatorControl to be ready for a new search
   * value.
   *
   * @param e ItemEvent
   * return  void
   */
  void jdbComboBox1_itemStateChanged(ItemEvent e) {
    jdbNavField1.setText("");
  }

  /**
   * When the user types in the JdbNavField, make sure that the ColumnName
   * property of the locatorControl is set to the column name selected in the
   * ChoiceControl.
   *
   * @param e KeyEvent
   * return  void
   */
  void jdbNavField1_keyPressed(KeyEvent e) {
    // Set the columnName property of the locatorControl
    // if it is not set.
    try {
      if ((jdbNavField1.getColumnName() == null) ||
          (jdbNavField1.getDataSet().getColumn(jdbNavField1.getColumnName()).getCaption().compareTo(jdbComboBox1.getSelectedItem()) != 0)) {
        Column [] columns = jdbNavField1.getDataSet().getColumns();
        for (int index = 0; index < columns.length; index++) {
          if (columns[index].getCaption().compareTo(jdbComboBox1.getSelectedItem()) == 0) {
            jdbNavField1.setColumnName(columns[index].getColumnName());
            break;
          }
        }
      }
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }

  void btnClose_actionPerformed(ActionEvent e) {
    setVisible(false);
    dispose();
  }

  /**
   * Sets the DataSet bound to data-aware controls. Creating a property in this
   * fashion allows subclasses to customize properties of a superclass using the
   * visual designer.
   *
   * @param dataSet DataSet
   * return  void
   */
  public void setDataSet(DataSet dataSet) {
    jdbStatusLabel1.setDataSet(dataSet);
    jdbNavField1.setDataSet(dataSet);
    jdbTable1.setDataSet(dataSet);
  }

  /**
   * Returns the DataSet bound to data-aware controls.
   *
   * @return DataSet
   * return  void
   */
  public DataSet getDataSet() {
    return jdbTable1.getDataSet();
  }

  /**
   * Sets the items displayed by the combo box. Creating a property in this
   * fashion allows subclasses to customize properties of a superclass using the
   * visual designer.
   *
   * @param items String[]
   * return  void
   */
  public void setComboBoxItems(String [] items) {
    jdbComboBox1.setItems(items);
  }

  public String [] getComboBoxItems() {
    return jdbComboBox1.getItems();
  }
}

⌨️ 快捷键说明

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