home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 1998 November
/
Chip_1998-11_cd.bin
/
tema
/
Cafe
/
WDESAMPL.BIN
/
ReplaceConfirmDialog.java
< prev
next >
Wrap
Text File
|
1998-02-26
|
4KB
|
167 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);
setVisible(false);
setSize(261,71);
setBackground(new Color(12632256));
confirmlabel = new java.awt.Label("Replace this occurrence?");
confirmlabel.setBounds(48,12,166,21);
add(confirmlabel);
btn_yes = new java.awt.Button();
btn_yes.setActionCommand("button");
btn_yes.setLabel("Yes");
btn_yes.setBounds(10,39,45,22);
add(btn_yes);
btn_no = new java.awt.Button();
btn_no.setActionCommand("button");
btn_no.setLabel("No");
btn_no.setBounds(68,39,45,22);
add(btn_no);
btn_cancel = new java.awt.Button();
btn_cancel.setActionCommand("button");
btn_cancel.setLabel("Cancel");
btn_cancel.setBounds(126,39,45,22);
add(btn_cancel);
cb_confirm = new java.awt.Checkbox("Confirm");
cb_confirm.setBounds(184,39,69,18);
add(cb_confirm);
setTitle("Dialog2");
//}}
//{{REGISTER_LISTENERS
SymWindow aSymWindow = new SymWindow();
addWindowListener(aSymWindow);
SymAction lSymAction = new SymAction();
btn_yes.addActionListener(lSymAction);
btn_no.addActionListener(lSymAction);
btn_cancel.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
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);
}
public synchronized void show()
{
Rectangle bounds = getParent().bounds();
Rectangle abounds = bounds();
move(bounds.x + (bounds.width - abounds.width)/ 2,
bounds.y + (bounds.height - abounds.height)/2);
super.show();
FRE.FindIt(); //Initiate first find
}
//{{DECLARE_CONTROLS
java.awt.Label confirmlabel;
java.awt.Button btn_yes;
java.awt.Button btn_no;
java.awt.Button btn_cancel;
java.awt.Checkbox cb_confirm;
//}}
FindReplace m_replace;
class SymWindow extends java.awt.event.WindowAdapter
{
public void windowClosing(java.awt.event.WindowEvent event)
{
Object object = event.getSource();
if (object == ReplaceConfirmDialog.this)
Dialog1_WindowClosing(event);
}
}
void Dialog1_WindowClosing(java.awt.event.WindowEvent event)
{
hide();
}
class SymAction implements java.awt.event.ActionListener
{
public void actionPerformed(java.awt.event.ActionEvent event)
{
Object object = event.getSource();
if (object == btn_yes)
btnYes_Action(event);
else if (object == btn_no)
btnNo_Action(event);
else if (object == btn_cancel)
btnCancel_Action(event);
}
}
void btnYes_Action(java.awt.event.ActionEvent event)
{
if(m_replace.isFoundIt()) {
m_replace.setIndex(FRE.ReplaceIt());
if(cb_confirm.getState()) {
FRE.ReplaceAll();
}
}
FRE.FindIt();
}
void btnNo_Action(java.awt.event.ActionEvent event)
{
FRE.FindIt();
}
void btnCancel_Action(java.awt.event.ActionEvent event)
{
hide();
}
}