home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Programming Languages Suite
/
ProgLangD.iso
/
VCAFE.3.0A
/
Sample.bin
/
FindDialog.java
< prev
next >
Wrap
Text File
|
1998-11-02
|
5KB
|
187 lines
/*
A basic extension of the java.awt.Dialog class
*/
import java.awt.*;
public class FindDialog extends Dialog {
public FindDialog(Frame parent, boolean modal)
{
super(parent, modal);
// This code is automatically generated by Visual Cafe when you add
// components to the visual environment. It instantiates and initializes
// the components. To modify the code, only use code syntax that matches
// what Visual Cafe can generate, or Visual Cafe may be unable to back
// parse your Java file into its visual environment.
//{{INIT_CONTROLS
setLayout(null);
setBackground(java.awt.Color.lightGray);
setSize(294,86);
setVisible(false);
m_findlabel.setText("Find What");
add(m_findlabel);
m_findlabel.setBounds(5,6,80,16);
add(m_findText);
m_findText.setBounds(5,30,190,20);
m_findButton.setLabel("Find");
add(m_findButton);
m_findButton.setBounds(209,6,70,20);
m_cancelButton.setLabel("Cancel");
add(m_cancelButton);
m_cancelButton.setFont(new Font("Dialog", Font.PLAIN, 12));
m_cancelButton.setBounds(209,30,70,20);
add(m_statuslabel);
m_statuslabel.setBounds(161,54,120,24);
m_statuslabel.setVisible(false);
m_matchCase.setLabel("Match case");
add(m_matchCase);
m_matchCase.setBackground(java.awt.Color.lightGray);
m_matchCase.setBounds(5,54,84,20);
setTitle("Dialog2");
//}}
//{{REGISTER_LISTENERS
SymWindow aSymWindow = new SymWindow();
this.addWindowListener(aSymWindow);
SymAction lSymAction = new SymAction();
m_findButton.addActionListener(lSymAction);
m_cancelButton.addActionListener(lSymAction);
//}}
}
public void addNotify()
{
// Record the size of the window prior to calling parents addNotify.
Dimension d = getSize();
super.addNotify();
if (fComponentsAdjusted)
return;
// Adjust components according to the insets
Insets insets = getInsets();
setSize(insets.left + insets.right + d.width, insets.top + insets.bottom + d.height);
Component components[] = getComponents();
for (int i = 0; i < components.length; i++)
{
Point p = components[i].getLocation();
p.translate(insets.left, insets.top);
components[i].setLocation(p);
}
fComponentsAdjusted = true;
}
// Used for addNotify check.
boolean fComponentsAdjusted = false;
public FindDialog(Frame parent, String title, boolean modal, FindReplace fr)
{
this(parent, modal);
setTitle(title);
m_find = fr;
m_findText.setText(m_find.getFind());
m_matchCase.setState(m_find.isCase());
}
//{{DECLARE_CONTROLS
java.awt.Label m_findlabel = new java.awt.Label();
java.awt.TextField m_findText = new java.awt.TextField();
java.awt.Button m_findButton = new java.awt.Button();
java.awt.Button m_cancelButton = new java.awt.Button();
java.awt.Label m_statuslabel = new java.awt.Label();
java.awt.Checkbox m_matchCase = new java.awt.Checkbox();
//}}
FindReplace m_find;
private void find()
{
FindReplaceEngine fre;
m_find.setFind(m_findText.getText().trim());
m_find.setCase(m_matchCase.getState());
fre = new FindReplaceEngine(m_find);
fre.FindIt();
if(m_find.isFoundIt()) m_statuslabel.setText("Found " + m_find.getOccur());
else {
m_statuslabel.setText("End of File");
this.getToolkit().beep();
}
m_statuslabel.setVisible(true);
}
class SymWindow extends java.awt.event.WindowAdapter
{
public void windowClosing(java.awt.event.WindowEvent event)
{
Object object = event.getSource();
if (object == FindDialog.this)
FindDialog_WindowClosing(event);
}
}
void FindDialog_WindowClosing(java.awt.event.WindowEvent event)
{
// to do: code goes here.
FindDialog_WindowClosing_Interaction1(event);
}
void FindDialog_WindowClosing_Interaction1(java.awt.event.WindowEvent event)
{
try {
this.dispose();
} catch (Exception e) {
}
}
class SymAction implements java.awt.event.ActionListener
{
public void actionPerformed(java.awt.event.ActionEvent event)
{
Object object = event.getSource();
if (object == m_findButton)
mFindButton_ActionPerformed(event);
else if (object == m_cancelButton)
mCancelButton_ActionPerformed(event);
}
}
void mFindButton_ActionPerformed(java.awt.event.ActionEvent event)
{
// to do: code goes here.
m_findButton_ActionPerformed_Interaction1(event);
}
void m_findButton_ActionPerformed_Interaction1(java.awt.event.ActionEvent event)
{
try {
this.find();
} catch (Exception e) {
}
}
void mCancelButton_ActionPerformed(java.awt.event.ActionEvent event)
{
// to do: code goes here.
m_cancelButton_ActionPerformed_Interaction1(event);
}
void m_cancelButton_ActionPerformed_Interaction1(java.awt.event.ActionEvent event)
{
try {
this.dispose();
} catch (Exception e) {
}
}
}