Results 1 to 2 of 2
  1. #1
    matt20687 is offline Member
    Join Date
    Jun 2012
    Posts
    5
    Rep Power
    0

    Default Java Netbeans - Search Module

    Hello,

    I have developed an application in Java using NetBeans, the application has a section which is used to contain a list of FAQ/How-to pages, these pages are accessed by a JList which contains a list of each page. An example of the code that allows the JList to become clickable is below:

    Java Code:
    //Dragon Profile Corrupt
             if (searchlist.getSelectedValue().equals("Dragon Profile Corrupt"))
                    {
                        java.awt.EventQueue.invokeLater(new Runnable() {
    @Override
    public void run() {
        new dragonprofilecorrupt().setVisible(true);
        FAQ.this.show(false);
        }
            });
                    }
    I have been asked if I can implement a search engine to make it easier to find these pages, there are quite a few now and to be fair it is getting confusing to find the page you want.

    My question is, how am I best to go about implementing this? Whilst researching I managed to make a very basic 'search' bar, this did find the pages but its not great, the searches are case sensitive and difficult to manage once more pages are added. An example is below:

    Java Code:
        private void searchActionPerformed(java.awt.event.ActionEvent evt) {                                       
           String searchtext = searchfield.getText().toString();
           if (searchtext.contains("monitor") || searchtext.contains("Monitor") || searchtext.contains("Dicom") || searchtext.contains("dicom") || searchtext.contains("DICOM"))
            {
            searchlist.setModel(new javax.swing.AbstractListModel() {
        String[] EveryCannedText = { 
            "Second Monitor Not Working",
        };
        public int getSize() { return EveryCannedText.length; }
        public Object getElementAt(int i) { return EveryCannedText[i]; }
        
        
    });
            }
    Any help will be greatly appreciated.

  2. #2
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,712
    Rep Power
    5

    Default Re: Java Netbeans - Search Module

    I advise you to research into using Apache Lucene; it is built to index and search documents. FAST. But its not easy technology to apply.

    Apache Lucene - Welcome to Apache Lucene

    Are all the document names hardcoded in the application? That seems very hard to maintain. I would rather store them in a file or something which you can load at startup. Heck I'd probably use a pure Java database to store all the documents such as H2.

    H2 Database Engine
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

Similar Threads

  1. Adding a module UML in NetBeans 6.5
    By Dimitri in forum NetBeans
    Replies: 0
    Last Post: 09-22-2011, 10:16 AM
  2. Replies: 0
    Last Post: 06-25-2011, 06:34 AM
  3. Netbeans Diff module
    By momcilo_jocic@yahoo.com in forum NetBeans
    Replies: 0
    Last Post: 07-16-2010, 06:06 PM
  4. Netbeans Platform and Module Dependencies
    By Josiah.Haswell in forum NetBeans
    Replies: 10
    Last Post: 08-07-2007, 12:43 AM
  5. Netbeans platform - JDBC module
    By sara in forum NetBeans
    Replies: 2
    Last Post: 07-10-2007, 01:21 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •