///////////////////////////////////////////////////////// // Module SearchPanel.java // Version 1.06 // Language Java // Author Sudhakar Chandrasekaran (thaths@netscape.com) // History // 05/16/97 Adding vectors and crawling // removed the dependancy on search() method in // MyFrame.java // 05/14/97 Added checking to prevent empty searches // // Legalese // Copyright (C) 1996-1997 Sudhakar Chandrasekharan // // This program is free software; you can redistribute it and/or modify it // under the terms of the GNU General Public License as published by the // Free Software Foundation; either version 2 of the license, or (at your // option) any later version. // // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. Writers of free software // cannot afford getting sued! // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 675 Mass Ave., Cambridge, MA 02139, USA. // // Sudhakar "Thaths" Chandrasekharan, 20 Apr 1997. //////////////////////////////////////////////////////// import java.awt.*; import SearchForText; public class SearchPanel extends Panel { MyFrame myFrame; TextField searchString; Button searchButton, clearButton; // Constructor SearchPanel(MyFrame mf) { myFrame = mf; searchString = new TextField(30); searchButton = new Button("Search"); clearButton = new Button("Clear"); clearButton.disable(); setLayout(new GridLayout(3,2)); add(new Label("Search for :")); add(searchString); add(searchButton); add(clearButton); } public void paint(Graphics g) { Dimension d = size(); Color bg = getBackground(); g.setColor(bg); g.draw3DRect(0,0,d.width-1,d.height-1,true); g.draw3DRect(2,2,d.width-5,d.height-5,false); } public Insets insets() { return new Insets(3,3,3,3); } public Dimension minimumSize() { Dimension d = new Dimension(400,70); return d; } public Dimension preferredSize() { Dimension d = new Dimension(400,70); return d; } public String getSearchText() { return searchString.getText(); } public boolean action(Event event, Object arg) { Object target = event.target; if (target == clearButton) { searchString.setText(""); myFrame.resultPanel.clearList(); clearButton.disable(); return true; } if (target == searchButton) { // If no text entered, don't search if (getSearchText().length() == 0) { return false; } // Do the search myFrame.resultPanel.numOfHits = 0; myFrame.clientSearch.pageDB.clear(); myFrame.resultPanel.clearList(); myFrame.currentPageNumber = 0; SearchForText searchForText; if (myFrame.optionsPanel.isCaseSensitiveSearch()) { searchForText = new SearchForText(myFrame, myFrame.clientSearch.openingPage, getSearchText()); } else { searchForText = new SearchForText(myFrame, myFrame.clientSearch.openingPage, getSearchText().toLowerCase()); } while (searchForText.isAlive()) { ; } return true; } return super.handleEvent(event); } }