///////////////////////////////////////////////////////// // Module OptionsPanel.java // Version 1.03 // Language Java // Author Sudhakar Chandrasekaran (thaths@netscape.com) // History Last Updated 12/4/97 // 05/17/97 Added isBooleanSearch(), isANDSearch(), isORSearch() // House cleaning // 05/16/97 Added caseSensitive() method // 04/20/97 Minor modifications // 12/03/97 Am attempting dramatic improvements long promised. Added // options panel (GUI) for case sensitive searches and bolean // seraches // 12/01/97 Added MenuBar and menu items. Still experimental. Changed // Copyright to GNU General Public License. // 11/21/96 Added ability to search (theoretically) any number of pages, // a primitive HTML parser and bug fixes // 11/05/96 Added code to pop up a seperate window // 11/02/96 Added multithreading for the process of searching // // 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.*; public class OptionsPanel extends Panel { MyFrame myFrame; CheckboxGroup booleanCheckboxGroup; Checkbox andCheckbox, orCheckbox, asStringCheckbox; Checkbox caseSensitivity; Panel casePanel; // Constructor OptionsPanel(MyFrame mf) { myFrame = mf; Panel booleanPanel; // The three checkboxes are created and grouped together booleanCheckboxGroup = new CheckboxGroup(); andCheckbox = new Checkbox("AND", booleanCheckboxGroup, false); orCheckbox = new Checkbox("OR", booleanCheckboxGroup, false); asStringCheckbox = new Checkbox("as a string", booleanCheckboxGroup, true); // For better layout, place groups of AWT components // in their own Panels booleanPanel = new Panel(); casePanel = new Panel(); // Layout the boolean search switches in thier panel booleanPanel.setLayout(new FlowLayout(FlowLayout.CENTER)); booleanPanel.add(andCheckbox); booleanPanel.add(orCheckbox); booleanPanel.add(asStringCheckbox); booleanPanel.validate(); booleanPanel.show(); // Create the checkbox for caseSensitivity caseSensitivity = new Checkbox("CaSe SeNsItIvE"); // Layout the case sensititvity switch in it's panel casePanel.setLayout(new FlowLayout(FlowLayout.CENTER)); casePanel.add(caseSensitivity); casePanel.validate(); casePanel.show(); setLayout(new GridLayout(3,1)); // Layout the switch panels add(new Label("Options", Label.CENTER)); add(booleanPanel); add(casePanel); validate(); show(); } // Method to find out if the caseSensitivity // switch is on public boolean isCaseSensitiveSearch() { return caseSensitivity.getState(); } // Method to find out if the search is AND or OR public boolean isBooleanSearch() { if (andCheckbox.getState() || orCheckbox.getState()) { return true; } else { return false; } } // Method to find out if the AND switch is on public boolean isANDSearch() { return andCheckbox.getState(); } // Method to find out if the OR switch is on public boolean isORSearch() { return orCheckbox.getState(); } // Paint a nice 3-d box around the panel 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); } // The padding for the chrome public Insets insets() { return new Insets(3,3,3,3); } // The minimum size of this panel public Dimension minimumSize() { Dimension d = new Dimension(400,70); return d; } // Would actually prefer it to be of this size public Dimension preferredSize() { Dimension d = new Dimension(400,70); return d; } // Even handler public boolean action(Event e, Object onWhat) { /* if (e.target instanceof Checkbox) { return true; } */ return super.handleEvent(e); } }