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

📄 searchform.java

📁 java 编写的图书管理系统
💻 JAVA
字号:
import com.ms.wfc.app.*;
import com.ms.wfc.core.*;
import com.ms.wfc.ui.*;
import com.ms.wfc.html.*;
import java.awt.event.*;

/**
 * This class can take a variable number of parameters on the command
 * line. Program execution begins with the main() method. The class
 * constructor is not invoked unless an object of type 'SearchForm'
 * created in the main() method.
 */
public class SearchForm extends Form
{
	protected Form1 m_Parent;
	int m_iIndex = 0;
	int m_iFindCount = 0 ;
	String m_sSearch;
	
	public SearchForm( )
	{
		super();

		// Required for Visual J++ Form Designer support
		initForm();	
		//m_Parent = fm1;

		// TODO: Add any constructor code after initForm call
	}

	/**
	 * SearchForm overrides dispose so it can clean up the
	 * component list.
	 */
	public void dispose()
	{
		super.dispose();
		components.dispose();
	}

	private void combBox_selectedIndexChanged(Object source, Event e)
	{
		if(combBox.getSelectedIndex () == 0)
		{
			this.m_iIndex = 0;
			labSearch.setText ("请输入所书号:");
		}
		if(combBox.getSelectedIndex () == 1)
		{
			this.m_iIndex = 1;
			labSearch.setText ("请输入书名:");
		}
		if(combBox.getSelectedIndex () == 2)
		{
			this.m_iIndex = 2;
			labSearch.setText ("请输入类别名:");
		}
		if(combBox.getSelectedIndex () == 3)
		{
			this.m_iIndex = 3;
			labSearch.setText("请输入作者名:");
		}
	}

	private void btnResult_click(Object source, Event e)
	{
		combBox.setSelectedIndex (0);
		editSearch.setText ("");
		labResult.setText ("");
		labFlag.setText ("");
		richEdit.setText ("");
	}

	private void btnClose_click(Object source, Event e)
	{
		this.dispose ();
	}

	private void btnEnter_click(Object source, Event e)
	{
		String m_sSearch = editSearch.getText ();
		String info = "";
		if(m_sSearch.equals (""))
			MessageBox.show ("请按要求填写!","提示:",MessageBox.ICONINFORMATION );
		else if(m_sSearch.equals ("*"))
		{
			int iCount = 0;
			this.m_iFindCount = m_Parent.m_nCount ;
			labResult.setText ("总共找到满足要求的书 "+ m_iFindCount +" 本.");
			for(;iCount < m_Parent.m_nCount ;iCount++)
				if(m_Parent.m_arBook[iCount] != null)
					info += m_Parent.m_arBook [iCount].toString () + "\n";
			labFlag.setText ("所书号\t书名\t类别\t作者\t数量\t价格");
			display(info);
		}
		else
		{
			int iCount = 0;
			for(;iCount < m_Parent.m_nCount ;iCount++)
			{
				if((m_Parent.m_arBook [iCount] != null) && (m_Parent.isEqual (m_sSearch, m_Parent.m_arBook [iCount].getMember (m_iIndex))))
				{	
					m_iFindCount++;
					info += m_Parent.m_arBook [iCount].toString () + "\n";
				}
			}
			labResult.setText ("总共找到满足要求的书 "+ m_iFindCount +" 本.");
			labFlag.setText ("所书号\t书名\t类别\t作者\t数量\t价格");
			display(info);
			
		}
		
		m_sSearch = "";
		m_iFindCount = 0;
		m_iIndex = 0;		
	}
	
	public void display(String info)
	{
		richEdit.setText (info);
	}

	
	/**
	 * NOTE: The following code is required by the Visual J++ form
	 * designer.  It can be modified using the form editor.  Do not
	 * modify it using the code editor.
	 */
	Container components = new Container();
	Button btnResult = new Button();
	GroupBox groupBox1 = new GroupBox();
	GroupBox groupBox2 = new GroupBox();
	Label label2 = new Label();
	Button btnEnter = new Button();
	RichEdit richEdit = new RichEdit();
	Label label1 = new Label();
	Label labSearch = new Label();
	Edit editSearch = new Edit();
	Label labResult = new Label();
	Button btnClose = new Button();
	Label labFlag = new Label();
	ComboBox combBox = new ComboBox();

	private void initForm()
	{
		// NOTE:  This form is storing resource information in an
		// external file.  Do not modify the string parameter to any
		// resources.getObject() function call. For example, do not
		// modify "foo1_location" in the following line of code
		// even if the name of the Foo object changes: 
		//   foo1.setLocation((Point)resources.getObject("foo1_location"));

		IResourceManager resources = new ResourceManager(this, "SearchForm");
		this.setText("Simple-SearchForm");
		this.setAutoScaleBaseSize(new Point(6, 12));
		this.setBorderStyle(FormBorderStyle.FIXED_DIALOG);
		this.setClientSize(new Point(394, 325));
		this.setIcon((Icon)resources.getObject("this_icon"));
		this.setMaximizeBox(false);
		this.setMinimizeBox(false);
		this.setShowInTaskbar(false);
		this.setStartPosition(FormStartPosition.CENTER_SCREEN);

		btnResult.setLocation(new Point(159, 126));
		btnResult.setSize(new Point(75, 23));
		btnResult.setTabIndex(6);
		btnResult.setText("重置(&R)");
		btnResult.addOnClick(new EventHandler(this.btnResult_click));

		groupBox1.setLocation(new Point(8, 7));
		groupBox1.setSize(new Point(264, 160));
		groupBox1.setTabIndex(4);
		groupBox1.setTabStop(false);
		groupBox1.setText("查询信息:");

		groupBox2.setLocation(new Point(4, 60));
		groupBox2.setSize(new Point(256, 96));
		groupBox2.setTabIndex(4);
		groupBox2.setTabStop(false);
		groupBox2.setText("");

		label2.setLocation(new Point(215, 28));
		label2.setSize(new Point(40, 23));
		label2.setTabIndex(1);
		label2.setTabStop(false);
		label2.setText("查询");

		btnEnter.setLocation(new Point(30, 126));
		btnEnter.setSize(new Point(75, 23));
		btnEnter.setTabIndex(7);
		btnEnter.setText("确定(&E)");
		btnEnter.addOnClick(new EventHandler(this.btnEnter_click));

		richEdit.setFont(Font.DEFAULT_GUI);
		richEdit.setForeColor(Color.WINDOWTEXT);
		richEdit.setLocation(new Point(14, 232));
		richEdit.setSize(new Point(368, 88));
		richEdit.setTabIndex(2);
		richEdit.setText("");
		richEdit.setReadOnly(true);

		label1.setLocation(new Point(16, 28));
		label1.setSize(new Point(24, 23));
		label1.setTabIndex(0);
		label1.setTabStop(false);
		label1.setText("按:");

		labSearch.setLocation(new Point(16, 92));
		labSearch.setSize(new Point(88, 23));
		labSearch.setTabIndex(2);
		labSearch.setTabStop(false);
		labSearch.setText("请输入所书号:");

		editSearch.setLocation(new Point(112, 88));
		editSearch.setSize(new Point(128, 19));
		editSearch.setTabIndex(5);
		editSearch.setText("");

		labResult.setFont(new Font("宋体", 11.0f, FontSize.POINTS, FontWeight.BOLD, false, false, false, CharacterSet.DEFAULT, 0));
		labResult.setLocation(new Point(16, 176));
		labResult.setSize(new Point(256, 24));
		labResult.setTabIndex(0);
		labResult.setTabStop(false);
		labResult.setText("");

		btnClose.setLocation(new Point(320, 32));
		btnClose.setSize(new Point(64, 23));
		btnClose.setTabIndex(1);
		btnClose.setText("关闭(&C)");
		btnClose.addOnClick(new EventHandler(this.btnClose_click));

		labFlag.setLocation(new Point(16, 208));
		labFlag.setSize(new Point(368, 16));
		labFlag.setTabIndex(3);
		labFlag.setTabStop(false);
		labFlag.setText("");

		combBox.setLocation(new Point(56, 24));
		combBox.setSize(new Point(144, 20));
		combBox.setTabIndex(3);
		combBox.setText("所书号");
		combBox.setItems(new Object[] {
						 "所书号", 
						 "书名", 
						 "类别", 
						 "作者"});
		combBox.addOnSelectedIndexChanged(new EventHandler(this.combBox_selectedIndexChanged));

		this.setNewControls(new Control[] {
							groupBox1, 
							labFlag, 
							richEdit, 
							btnClose, 
							labResult});
		groupBox1.setNewControls(new Control[] {
								 combBox, 
								 label2, 
								 label1, 
								 labSearch, 
								 editSearch, 
								 btnEnter, 
								 btnResult, 
								 groupBox2});
	}

	/**
	 * The main entry point for the application. 
	 *
	 * @param args Array of parameters passed to the application
	 * via the command line.
	 */
	public static void main(String args[])
	{
		Application.run(new SearchForm());
	}
}

⌨️ 快捷键说明

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