home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Programming Languages Suite
/
ProgLangD.iso
/
VCAFE.3.0A
/
Sample.bin
/
ReplaceConfirmDialog.java
< prev
next >
Wrap
Text File
|
1998-11-02
|
5KB
|
200 lines
/*
A basic extension of the java.awt.Dialog class
*/
import java.awt.*;
public class ReplaceConfirmDialog extends Dialog {
FindReplaceEngine FRE;
public ReplaceConfirmDialog(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(261,71);
setVisible(false);
confirmlabel.setText("Replace this occurrence?");
add(confirmlabel);
confirmlabel.setBounds(48,12,166,21);
btnYes.setActionCommand("button");
btnYes.setLabel("Yes");
add(btnYes);
btnYes.setBounds(10,39,45,22);
btnNo.setActionCommand("button");
btnNo.setLabel("No");
add(btnNo);
btnNo.setBounds(68,39,45,22);
btnCancel.setActionCommand("button");
btnCancel.setLabel("Cancel");
add(btnCancel);
btnCancel.setBounds(126,39,45,22);
cb_confirm.setLabel("Confirm");
add(cb_confirm);
cb_confirm.setBounds(184,39,69,18);
setTitle("Dialog2");
//}}
//{{REGISTER_LISTENERS
SymWindow aSymWindow = new SymWindow();
addWindowListener(aSymWindow);
SymAction lSymAction = new SymAction();
btnYes.addActionListener(lSymAction);
btnNo.addActionListener(lSymAction);
btnCancel.addActionListener(lSymAction);
this.addWindowListener(aSymWindow);
//}}
}
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 ReplaceConfirmDialog(Frame parent, String title, boolean modal, FindReplace replace)
{
this(parent, modal);
setTitle(title);
m_replace = replace;
FRE = new FindReplaceEngine(m_replace);
}
//{{DECLARE_CONTROLS
java.awt.Label confirmlabel = new java.awt.Label();
java.awt.Button btnYes = new java.awt.Button();
java.awt.Button btnNo = new java.awt.Button();
java.awt.Button btnCancel = new java.awt.Button();
java.awt.Checkbox cb_confirm = new java.awt.Checkbox();
//}}
FindReplace m_replace;
private void replace()
{
if(m_replace.isFoundIt()) {
m_replace.setIndex(FRE.ReplaceIt());
if(cb_confirm.getState()) {
FRE.ReplaceAll();
}
}
find();
}
public void find()
{
FRE.FindIt();
}
class SymWindow extends java.awt.event.WindowAdapter
{
public void windowClosing(java.awt.event.WindowEvent event)
{
Object object = event.getSource();
if (object == ReplaceConfirmDialog.this)
ReplaceConfirmDialog_WindowClosing(event);
}
}
void ReplaceConfirmDialog_WindowClosing(java.awt.event.WindowEvent event)
{
ReplaceConfirmDialog_WindowClosing_Interaction1(event);
}
void ReplaceConfirmDialog_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 == btnYes)
btnYes_ActionPerformed(event);
else if (object == btnNo)
btnNo_ActionPerformed(event);
else if (object == btnCancel)
btnCancel_ActionPerformed(event);
}
}
void btnYes_ActionPerformed(java.awt.event.ActionEvent event)
{
// to do: code goes here.
btnYes_ActionPerformed_Interaction1(event);
}
void btnYes_ActionPerformed_Interaction1(java.awt.event.ActionEvent event)
{
try {
this.replace();
} catch (Exception e) {
}
}
void btnNo_ActionPerformed(java.awt.event.ActionEvent event)
{
btnNo_ActionPerformed_Interaction1(event);
}
void btnCancel_ActionPerformed(java.awt.event.ActionEvent event)
{
btnCancel_ActionPerformed_Interaction1(event);
}
void btnCancel_ActionPerformed_Interaction1(java.awt.event.ActionEvent event)
{
try {
this.dispose();
} catch (Exception e) {
}
}
void btnNo_ActionPerformed_Interaction1(java.awt.event.ActionEvent event)
{
try {
this.find();
} catch (Exception e) {
}
}
}