Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Text Finder Write a Java GUI application functioning as a simple text search eng

ID: 3816190 • Letter: T

Question

Text Finder

Write a Java GUI application functioning as a simple text search engine. It allows a user to input a search string, and highlights all occurrences of the string in a given text. For instance, the given text is the following paragraph, and the user input the string ‘man’. All two occurences are highlighted as shown.

“There worse by an of miles civil. Manner before lively wholly am mr indeed expect. Among every merry his yet has her. You mistress get dashwood children off. Met whose marry under the merit. In it do continual consulted no listening. Devonshire sir sex motionless travelling six themselves. So colonel as greatly shewing herself observe ashamed. Demands minutes ”

Explanation / Answer

      This is the code to search, that i have used.. i have to use pattern matching technique to search the files by giving only the file name or to get the file which is having the contents when we give the content to search.
Please help me.. Thanks...   

b.setActionCommand("search");

         

         b.addActionListener(new ActionListener()

         {

               public void actionPerformed(ActionEvent e)

               {

                    String s=b.getActionCommand();

                     if(s.equals("search"))

                     {

                         String tf=f.getText();

                         System.out.println(tf);

                         if(tf.equals(""))

                         {

                             output.setText("");

                             output.setEditable(false);

                             

                             JPanel listContainer = new JPanel(new GridLayout(1,1));

                             listContainer.setBorder(BorderFactory.createTitledBorder("RESULT"));

                             listContainer.add(new JLabel("PATH NOT FOUND"));

                          

                             splitPane.setBottomComponent(listContainer);

                           }

                           else

                           {

                               file = new File(tf);

                               listData = file.listFiles();

                               list = new JList(listData);

                           

                               listSelectionModel = list.getSelectionModel();

                               listSelectionModel.addListSelectionListener(new SharedListSelectionHandler());

                               JScrollPane listPane1 = new JScrollPane(list);

                             

                               JPanel listContainer1 = new JPanel(new GridLayout(1,1));

                               listContainer1.setBackground(Color.LIGHT_GRAY);

                               listContainer1.setBorder(BorderFactory.createTitledBorder("List"));

                               listContainer1.add(listPane1);

                               output.setEditable(true);

                               splitPane.setBottomComponent(listContainer1);

                               

                           }

                       

                       }

                    }

                }

            );

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote