home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Programming Languages Suite
/
ProgLangD.iso
/
VCAFE.3.0A
/
Sample.bin
/
AlertDialog.java
< prev
next >
Wrap
Text File
|
1998-11-05
|
8KB
|
254 lines
// Copyright (c) 1997, 1998 Symantec, Inc. All Rights Reserved.
import java.awt.*;
import symantec.itools.multimedia.ImageViewer;
import symantec.itools.awt.WrappingLabel;
/**
* This dialog was added to this project by dragging a Dialog form component
* into the project.
* It was then customized with Cafe's visual tools, including the Interaction
* Wizard.
* Then it was manually customized to
* 1) allow construction with just one (OK) button or two (OK and Cancel)
* 2) note the results in the main/only WebLogAnalyzer instance
*/
public class AlertDialog extends Dialog {
/*
This constructor creates and shows the typical OK/Cancel alert dialog
with the specified message.
*/
public AlertDialog(Frame parent, String text)
{
this(parent, true, text);
}
/*
This constructor creates and shows an alert with or without a Cancel
button.
*/
public AlertDialog(Frame parent, boolean bCancelButton, String text)
{
this(parent, true);
try {
setTextLabel.setText(text);
}
catch(java.beans.PropertyVetoException e) { }
// Hide cancel button, as needed
if(!bCancelButton) {
// move the OK button to the lower right where the Cancel button was
Rectangle r = cancelButton.getBounds();
cancelButton.setVisible(false);
panel1.remove(cancelButton);
Rectangle pr = panel1.getBounds();
panel1.setBounds(pr.x + r.width, pr.y, pr.width - r.width, pr.height);
}
show();
}
// -- AUTOMATICALLY GENERATED/MAINTAINED CODE FRAMEWORK BELOW THIS LINE --
/**
* Constructs this dialog.
* Initializes components the components.
* Registers component listeners.
* All of the code in this routine are automatically generated/maintained
* by Visual Cafe.
*/
public AlertDialog(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(416,114);
setVisible(false);
try {
imageViewer1.setImageURL(symantec.itools.net.RelativeURL.getURL("images/wl-bang.jpg"));
}
catch (java.net.MalformedURLException error) { }
catch(java.beans.PropertyVetoException e) { }
try {
imageViewer1.setStyle(symantec.itools.multimedia.ImageViewer.IMAGE_NORMAL);
}
catch(java.beans.PropertyVetoException e) { }
add(imageViewer1);
imageViewer1.setBounds(7,9,64,94);
add(setTextLabel);
setTextLabel.setBounds(86,12,307,63);
panel1.setLayout(new GridLayout(1,1,8,0));
add(panel1);
panel1.setBounds(271,80,121,23);
okButton.setLabel("OK");
panel1.add(okButton);
okButton.setBounds(0,0,56,23);
cancelButton.setLabel("Cancel");
panel1.add(cancelButton);
cancelButton.setBounds(64,0,56,23);
setTitle("Alert");
//}}
//{{REGISTER_LISTENERS
SymWindow aSymWindow = new SymWindow();
this.addWindowListener(aSymWindow);
SymAction lSymAction = new SymAction();
okButton.addActionListener(lSymAction);
cancelButton.addActionListener(lSymAction);
//}}
// Center this dialog within its parent's bounds
WLAUtil.centerInParent(this);
}
/**
* Constructs this Dialog with the given title.
* This routine was automatically generated by Visual Cafe, and is not
* actually used.
*/
public AlertDialog(Frame parent, String title, boolean modal)
{
this(parent, modal);
setTitle(title);
}
/**
* Tells this component that it has been added to a container.
* This is a standard Java AWT method which gets called by the AWT when
* this component is added to a container.
* Typically, it is used to create this component's peer. <br>
* It has been OVERRIDDEN here to adjust the position of components as needed
* for the container's insets. <br>
* This method is automatically generated by Visual Cafe.
*/
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;
//{{DECLARE_CONTROLS
symantec.itools.multimedia.ImageViewer imageViewer1 = new symantec.itools.multimedia.ImageViewer();
symantec.itools.awt.WrappingLabel setTextLabel = new symantec.itools.awt.WrappingLabel();
java.awt.Panel panel1 = new java.awt.Panel();
java.awt.Button okButton = new java.awt.Button();
java.awt.Button cancelButton = new java.awt.Button();
//}}
/**
* This is an event listener created by Visual Cafe to handle WindowEvents.
*/
class SymWindow extends java.awt.event.WindowAdapter
{
public void windowOpened(java.awt.event.WindowEvent event)
{
Object object = event.getSource();
if (object == AlertDialog.this)
AlertDialog_WindowOpen(event);
}
public void windowClosing(java.awt.event.WindowEvent event)
{
Object object = event.getSource();
if (object == AlertDialog.this)
AlertDialog_WindowClosing(event);
}
}
/**
* Handles the WINDOW_CLOSING WindowEvent.
* This method is automatically added when the Dialog form was added to
* this project.
*/
void AlertDialog_WindowClosing(java.awt.event.WindowEvent event)
{
dispose();
}
/**
* This is an event listener created by Visual Cafe to handle ActionEvents.
* It was created by the Interaction Wizard.
*/
class SymAction implements java.awt.event.ActionListener
{
public void actionPerformed(java.awt.event.ActionEvent event)
{
Object object = event.getSource();
if (object == okButton)
okButton_Clicked(event);
else if (object == cancelButton)
cancelButton_Action(event);
}
}
/**
* This handles the ActionEvents generated by the OK button.
* Created using the Interaction Wizard, then the modified to
* note "OK" in the main/only WebLogAnalyzer instance.
*/
void okButton_Clicked(java.awt.event.ActionEvent event)
{
((WebLogAnalyzer)getParent()).alertOKd = true;
//{{CONNECTION
// Clicked from okButton Hide the Dialog
dispose();
//}}
}
/*
Created by pulling down the "Events/Methods" choice in the source window
and selecting WindowOpen. Then modified to
init "Cancel" in the main/only WebLogAnalyzer instance.
*/
void AlertDialog_WindowOpen(java.awt.event.WindowEvent event)
{
// to do: code goes here.
// Do window-opening init
((WebLogAnalyzer)getParent()).alertOKd = false;
}
/**
* This handles the ActionEvents generated by the Cancel button.
* Created using the Interaction Wizard.
*/
void cancelButton_Action(java.awt.event.ActionEvent event)
{
// to do: code goes here.
//{{CONNECTION
// Hide the Dialog
setVisible(false);
//}}
}
}