《SSD4实验七实验报告.doc》由会员分享,可在线阅读,更多相关《SSD4实验七实验报告.doc(12页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、实验七一、 实验目的编写一个应用程序可用于方便记忆五个IPM,并能进行启发式的搜索二、 实验内容要求:1 能够对选择的IPM内容显示在编辑域中2 能对输入的字符串进行搜索查询,并在label中显示其出现在那个IPM3 能进行报错处理三、 实验步骤和结果实验代码import java.util.regex.Pattern;import javax.swing.JOptionPane;import javax.swing.JScrollPane;import javax.swing.UIManager;import javax.swing.event.DocumentEvent;import ja
2、vax.swing.event.DocumentListener; * To change this template, choose Tools | Templates * and open the template in the editor. * SSD4.java * Created on 2012-12-10, 19:06:44 * author Administratorpublic class SSD4 extends javax.swing.JFrame /* Creates new form SSD4 */ public SSD4() initComponents(); /*
3、 This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. SuppressWarnings(unchecked) / private void initComponents() jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.
4、swing.JLabel(); jLabel3 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); jLabel6 = new javax.swing.JLabel(); jScrollPane1 = new javax.swing.JScrollPane(); jTextArea1 = new javax.swing.JTextArea(); jLabel7 = new javax.swing.JLabel(); jLabel8 = new ja
5、vax.swing.JLabel(); jLabel9 = new javax.swing.JLabel(); jTextField1 = new javax.swing.JTextField(); jTextField2 = new javax.swing.JTextField(); jButton1 = new javax.swing.JButton(); jButton2 = new javax.swing.JButton(); jLabel10 = new javax.swing.JLabel(); jLabel11 = new javax.swing.JLabel(); jLabel
6、12 = new javax.swing.JLabel(); jLabel13 = new javax.swing.JLabel(); jLabel14 = new javax.swing.JLabel(); jButton3 = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setName(HeuristicHelper); / NOI18N jLabel1.setFont(new java.awt.Font(宋体, 1, 14); jLabel1
7、.setText(Heuristic); jLabel2.setText(1.Visibility of System Status); jLabel3.setText(2.User Control and Freedom); jLabel4.setText(3.Error Prevention); jLabel5.setText(4.Flexibility and Efficiency of Use); jLabel6.setText(5.Help Users Recognize, Diagnose, and Recover from Errors); jTextArea1.setColum
8、ns(20); jTextArea1.setEditable(false); jTextArea1.setLineWrap(true); jTextArea1.setRows(5); jTextArea1.setToolTipText(Text displayed here); jScrollPane1.setViewportView(jTextArea1); jLabel7.setFont(new java.awt.Font(Times New Roman, 1, 14); jLabel7.setText(Relationship to a users information progres
9、sing model); jLabel8.setFont(new java.awt.Font(Times New Roman, 0, 12); jLabel8.setText(Select a heuristic by number); jLabel9.setFont(new java.awt.Font(Times New Roman, 0, 12); jLabel9.setText(Enter a key or string); jTextField1.setToolTipText(Enter you text selection here); jTextField1.setSelectio
10、nColor(new java.awt.Color(0, 255, 255); jTextField1.addCaretListener(new javax.swing.event.CaretListener() public void caretUpdate(javax.swing.event.CaretEvent evt) jTextField1CaretUpdate(evt); jTextField1.addActionListener(new java.awt.event.ActionListener() public void actionPerformed(java.awt.eve
11、nt.ActionEvent evt) jTextField1ActionPerformed(evt); jTextField1.addFocusListener(new java.awt.event.FocusAdapter() public void focusGained(java.awt.event.FocusEvent evt) jTextField1FocusGained(evt); public void focusLost(java.awt.event.FocusEvent evt) jTextField1FocusLost(evt); jTextField1.addHiera
12、rchyListener(new java.awt.event.HierarchyListener() public void hierarchyChanged(java.awt.event.HierarchyEvent evt) jTextField1HierarchyChanged(evt); jTextField1.addInputMethodListener(new java.awt.event.InputMethodListener() public void caretPositionChanged(java.awt.event.InputMethodEvent evt) jTex
13、tField1CaretPositionChanged(evt); public void inputMethodTextChanged(java.awt.event.InputMethodEvent evt) jTextField1InputMethodTextChanged(evt); jTextField1.addPropertyChangeListener(new java.beans.PropertyChangeListener() public void propertyChange(java.beans.PropertyChangeEvent evt) jTextField1Pr
14、opertyChange(evt); jTextField1.addKeyListener(new java.awt.event.KeyAdapter() public void keyPressed(java.awt.event.KeyEvent evt) jTextField1KeyPressed(evt); jTextField1.addVetoableChangeListener(new java.beans.VetoableChangeListener() public void vetoableChange(java.beans.PropertyChangeEvent evt)th
15、rows java.beans.PropertyVetoException jTextField1VetoableChange(evt); jTextField2.setToolTipText(Type in the string); jTextField2.addKeyListener(new java.awt.event.KeyAdapter() public void keyPressed(java.awt.event.KeyEvent evt) jTextField2KeyPressed(evt); jButton1.setText(Display a relationship); j
16、Button1.setToolTipText(Display the text); jButton1.addActionListener(new java.awt.event.ActionListener() public void actionPerformed(java.awt.event.ActionEvent evt) jButton1ActionPerformed(evt); jButton2.setText(Search relationships); jButton2.setToolTipText(Search for the string entered); jButton2.
17、addActionListener(new java.awt.event.ActionListener() public void actionPerformed(java.awt.event.ActionEvent evt) jButton2ActionPerformed(evt); jLabel10.setFont(new java.awt.Font(Times New Roman, 1, 12); / NOI18N jLabel10.setText(Other IPMs the search string occurs in (by the name); jButton3.setText
18、(Exit); jButton3.addActionListener(new java.awt.event.ActionListener() public void actionPerformed(java.awt.event.ActionEvent evt) jButton3ActionPerformed(evt); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane(); getContentPane().setLayout(layout); layout.setHorizontalGrou
19、p( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.c
20、reateSequentialGroup() .addGap(23, 23, 23) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel2) .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel5) .addComponent(jLabel6) .
21、addComponent(jLabel3) .addComponent(jLabel4) .addGroup(layout.createSequentialGroup() .addGap(20, 20, 20) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE) .addCo
22、mponent(jLabel9) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 5, Short.MAX_VALUE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(jTextField2) .addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 72, Short.MAX_
23、VALUE) .addGap(21, 21, 21) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.s
24、wing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.A
25、lignment.TRAILING, false) .addComponent(jLabel12, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel13, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 337, Shor
26、t.MAX_VALUE) .addComponent(jLabel14, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(33
27、, Short.MAX_VALUE) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 342, S
28、hort.MAX_VALUE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(jLabel7, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel11, javax.swing.G
29、roupLayout.DEFAULT_SIZE, 342, Short.MAX_VALUE) .addComponent(jLabel10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(28, 28, 28) layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.crea
30、teSequentialGroup() .addGap(31, 31, 31) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel1) .addComponent(jLabel7) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequential
31、Group() .addComponent(jLabel2) .addGap(18, 18, 18) .addComponent(jLabel3) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jLabel4) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 14, Short.MAX_VALUE) .addComponent(jLabel5) .addGap(18, 18, 18)
32、 .addComponent(jLabel6) .addGap(45, 45, 45) .addGroup(layout.createSequentialGroup() .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGr
33、oup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jButton1) .addComponent(jLabel8) .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLay
34、out.PREFERRED_SIZE) .addGroup(layout.createSequentialGroup() .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel10) .addGap(6, 6, 6) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(
35、6, 6, 6) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jButton2) .addComponent(jLabel9) .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(layout.c
36、reateSequentialGroup() .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(2, 2, 2) .addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.Gro
37、upLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jLabel14, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(28, 28, 28) .addComponent(jButton3) .addContainerGap() pack(); / private void jTextField1VetoableChange(java.beans.PropertyChangeEvent evt)throws java.beans.PropertyVetoException / TODO add your handling code here: