Back to index

wims  3.65+svn20090927
FindDialog.java
Go to the documentation of this file.
00001 /*
00002  * @(#)FindDialog.java
00003  *
00004  * $Id: FindDialog.java,v 1.3 2001/05/27 22:28:57 huaz Exp $
00005  *
00006  * Created on November 28, 2000, 02:12 AM
00007  */
00008 package SharpTools;
00009 import javax.swing.*;
00010 import java.awt.*;
00011 import javax.swing.BorderFactory;
00012 import javax.swing.border.Border;
00013 import java.awt.event.*;
00014 
00023 public class FindDialog extends SharpDialog {
00024     
00025     private JLabel label;
00026     private JFrame frame;
00027     final private JTextField textField = new JTextField(10);
00028     private JCheckBox caseSensitiveBox;
00029     private JCheckBox matchCellBox;
00030     private String typedText = null;
00031     private boolean caseSensitive = false;
00032     private boolean matchCell = false;
00033     final ImageIcon findIcon=new ImageIcon(getClass().getResource("/images/find32.gif"));
00034     //final private ImageIcon findIcon = SharpTools.getImageIcon("find32.gif");
00035 
00036     public FindDialog(JFrame aFrame, String findValue, boolean mCase,
00037                     boolean mCell) {
00038        super(aFrame, "Find", true);
00039        
00040        textField.setText(findValue);
00041        
00042        caseSensitiveBox = new JCheckBox(SharpTools.translation.getProperty("Match_Case"));
00043        caseSensitiveBox.setMnemonic(KeyEvent.VK_M);
00044        caseSensitiveBox.setSelected(mCase);
00045        
00046        matchCellBox = new JCheckBox(SharpTools.translation.getProperty("Match_Entire_Cell_Only"));
00047        matchCellBox.setMnemonic(KeyEvent.VK_E); 
00048        matchCellBox.setSelected(mCell);
00049 
00050        JPanel box = new JPanel(new BorderLayout(0, 5));
00051 
00052        box.add(textField, BorderLayout.NORTH);
00053        box.add(caseSensitiveBox, BorderLayout.WEST);
00054        box.add(matchCellBox, BorderLayout.EAST);
00055        
00056        setOptionPane(box, 
00057                     JOptionPane.PLAIN_MESSAGE,
00058                     JOptionPane.OK_CANCEL_OPTION,
00059                     findIcon);     
00060     }
00061     
00062     public boolean isCaseSensitive(){
00063        return caseSensitive;              
00064     }
00065     
00066     public boolean isCellMatching(){
00067        return matchCell;
00068     }
00069     
00070     public String getString(){
00071        return typedText;
00072     }
00073 
00074     protected void onOpen() {
00075        textField.selectAll();
00076        textField.requestFocus();
00077     }
00078 
00079     protected boolean onOK() {
00080        typedText = textField.getText();
00081        caseSensitive = caseSensitiveBox.isSelected();
00082        matchCell = matchCellBox.isSelected();
00083        return true;
00084     }
00085 }